-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
java.lang.ArrayIndexOutOfBoundsException at CBORGenerator.java:548 #62
Comments
It looks like
doesn't work quite right. However, just adding the
guard to the methods I mentioned does the trick. |
Thank you for reporting this. The usual version check: is this against 2.8.7 (or 2.9.0.pr1), or some older version? |
Running with 2.8.6. The snippets of code I copied are from the github repository though (so 2.8.7, or 2.9.0?). |
Ok, this must be via contribution, and for 2.8. Obvious oversight, not sure how I did not catch it... especially since line 556 has proper handling (second one you suggested). I think it's ok not to check for negative indices given that code handles matching of start/end via states, although if it can become problematic it can definitely be added: these calls are not that numerous. |
Thanks for fixing. You've been a real pro about the tickets I've submitted. |
Thank you for submitting them! Should go without saying that these make my work much easier, when there's full info on what is going wrong. And encoding/decoding failures are critical to fix as there's usually no work around. |
I am encountering index out of bound exceptions at CBORGenerator.java:548 when performing serialization with a
new ObjectMapper(new CBORFactory())
instance. I haven't done a full investigation of the cause since calls toCBORGenerator::writeStartObject
are very stateful. Here is the offending function.An example error producing call has
_elementCountsPtr = 11
and_elementCounts.length = 10
. My guess at a solution and my current workaround is to add a safety check like inCBORGenerator::writeStartArray
. Here is that function.As you can see, the function resizes the _elementCounts array when required. I don't know what kind of coding styles you want to employ, but I would change the offending section in every
writeStartArray
andwriteStartObject
overload to read:Sorry I couldn't be more helpful with regard to why it is happening. Though I'd be happy to make a pull request with my described solution. Let me know what you think.
The text was updated successfully, but these errors were encountered: