File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,13 @@ void encode(ByteList src) throws IOException {
2323 int beg = 0 ;
2424 int pos = 0 ;
2525
26- ByteBuffer bb = ByteBuffer .wrap (ptrBytes , 0 , len );
27- while (ptr + pos + 8 <= len ) {
28- long x = bb .getLong (ptr + pos );
26+ // There are optimizations in JRuby where ptr > 0 will be true. For example, if we
27+ // slice a string, the underlying byte array is the same, but the
28+ // begin index and real size are different. When reading from the ptrBytes
29+ // array, we need to always add ptr to the index.
30+ ByteBuffer bb = ByteBuffer .wrap (ptrBytes , ptr , len );
31+ while (pos + 8 <= len ) {
32+ long x = bb .getLong (pos );
2933 if (skipChunk (x )) {
3034 pos += 8 ;
3135 continue ;
@@ -43,8 +47,8 @@ void encode(ByteList src) throws IOException {
4347 }
4448 }
4549
46- if (ptr + pos + 4 <= len ) {
47- int x = bb .getInt (ptr + pos );
50+ if (pos + 4 <= len ) {
51+ int x = bb .getInt (pos );
4852 if (skipChunk (x )) {
4953 pos += 4 ;
5054 }
You can’t perform that action at this time.
0 commit comments