You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code attempts to increase the size of the buffer with a 2x multiplier until no further bytes are available. I have some concerns about this (but no concrete solution) because this in-memory approach is not a true stream. But, that aside, the following code within keepSkippedBytesThenRead(...) causes a problem:
byte[] newBuf = new byte[iter.buf.length * 2];
This leads to rapid increases in memory allocation for the buffer. When processing a large input you can easily roll to a negative integer and then you will obviously end up with an allocation error as the length is negative. A better approach, which I'll check in shortly, is to only increase the length of the byte array by the increment of the initially provided size in the JsonIter.parse(...). A more meaningful error than the negative index is also advised.
The text was updated successfully, but these errors were encountered:
keepSkippedBytesThenRead is only used when readAny which means skip and copy the bytes. It is not involved in normal encoding process. Keep bytes in memory is expected in this case.
The code attempts to increase the size of the buffer with a 2x multiplier until no further bytes are available. I have some concerns about this (but no concrete solution) because this in-memory approach is not a true stream. But, that aside, the following code within keepSkippedBytesThenRead(...) causes a problem:
byte[] newBuf = new byte[iter.buf.length * 2];
This leads to rapid increases in memory allocation for the buffer. When processing a large input you can easily roll to a negative integer and then you will obviously end up with an allocation error as the length is negative. A better approach, which I'll check in shortly, is to only increase the length of the byte array by the increment of the initially provided size in the JsonIter.parse(...). A more meaningful error than the negative index is also advised.
The text was updated successfully, but these errors were encountered: