Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfRangeException in OSCPackerString.BytesToValue() #31

Closed
ahihi opened this issue Nov 24, 2023 · 2 comments
Closed

IndexOutOfRangeException in OSCPackerString.BytesToValue() #31

ahihi opened this issue Nov 24, 2023 · 2 comments

Comments

@ahihi
Copy link

ahihi commented Nov 24, 2023

with OSCReceiver, receiving OSCMessages of the form /orientation/supperware/quaternion 0.9975586 0.06152344 -0.01367188 -0.01708984 throws:

[OSCReceiver] Receive error: System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at extOSC.Core.Packers.OSCPackerString.BytesToValue (System.Byte[] buffer, System.Int32& index) [0x00012] in [...]/Assets/extOSC/Scripts/Core/Packers/OSCPackerString.cs:23 
  at extOSC.Core.Packers.OSCPacker`1[T].Unpack (System.Byte[] bytes, System.Int32& start) [0x00001] in [...]/Assets/extOSC/Scripts/Core/Packers/OSCPacker.cs:38 
  at extOSC.Core.OSCConverter.UnpackValue (extOSC.OSCValueType valueType, System.Byte[] bytes, System.Int32& start) [0x00035] in [...]/Assets/extOSC/Scripts/Core/OSCConverter.cs:349 
  at extOSC.Core.OSCConverter.UnpackMessage (System.Byte[] bytes, System.Int32& start) [0x00011] in [...]/Assets/extOSC/Scripts/Core/OSCConverter.cs:282 
  at extOSC.Core.OSCConverter.UnpackInternal (System.Byte[] bytes, System.Int32& start, System.Int32 end) [0x00017] in [...]/Assets/extOSC/Scripts/Core/OSCConverter.cs:250 
  at extOSC.Core.OSCConverter.Unpack (System.Byte[] buffer, System.Int32 length) [0x00015] in [...]/Assets/extOSC/Scripts/Core/OSCConverter.cs:136 
  at extOSC.Core.OSCConverter.Unpack (System.Byte[] bytes) [0x00013] in [...]/Assets/extOSC/Scripts/Core/OSCConverter.cs:127 
  at extOSC.Core.Network.OSCReceiverStandaloneBackend.Receive (System.Net.Sockets.UdpClient receivedClient, System.IAsyncResult result) [0x0001e] in [...]/Assets/extOSC/Scripts/Core/Network/OSCReceiverStandaloneBackend.cs:137 
UnityEngine.Debug:LogError (object)
extOSC.Core.Network.OSCReceiverStandaloneBackend:Receive (System.Net.Sockets.UdpClient,System.IAsyncResult) (at Assets/extOSC/Scripts/Core/Network/OSCReceiverStandaloneBackend.cs:151)
extOSC.Core.Network.OSCReceiverStandaloneBackend:ControllerThread (System.IAsyncResult) (at Assets/extOSC/Scripts/Core/Network/OSCReceiverStandaloneBackend.cs:110)
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback ()

the line in question is:

while (buffer[position] != 0 && position < buffer.Length)

i dont know exactly how we get here, but at the time of the exception we have position == buffer.Length. perhaps the position < buffer.Length check is meant to guard against this, but of course it does not help since it happens after the invalid indexing.

swapping the conditions to:

while (position < buffer.Length && buffer[position] != 0)

seems to fix it.

@Iam1337
Copy link
Owner

Iam1337 commented Jan 10, 2024

Hi! I apologize very much for such a late response. I will fix this error soon as possibly.

@Iam1337
Copy link
Owner

Iam1337 commented Jan 28, 2024

Fixed in c9622a8. Thanks!

@Iam1337 Iam1337 closed this as completed Jan 28, 2024
Iam1337 added a commit that referenced this issue Jan 28, 2024
github-actions bot pushed a commit that referenced this issue Jan 28, 2024
## [1.20.4](v1.20.3...v1.20.4) (2024-01-28)

### Bug Fixes

* **ci:** fixed issue [#31](#31) ([6658542](6658542))
github-actions bot pushed a commit that referenced this issue Jan 28, 2024
github-actions bot pushed a commit that referenced this issue Jan 28, 2024
## [1.20.4](v1.20.3...v1.20.4) (2024-01-28)

### Bug Fixes

* **ci:** fixed issue [#31](#31) ([6658542](6658542))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants