Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions java/src/json/ext/SWARBasicStringEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ void encode(ByteList src) throws IOException {
// slice a string, the underlying byte array is the same, but the
// begin index and real size are different. When reading from the ptrBytes
// array, we need to always add ptr to the index.
ByteBuffer bb = ByteBuffer.wrap(ptrBytes, ptr, len);
ByteBuffer bb = ByteBuffer.wrap(ptrBytes, 0, ptr + len);

while (pos + 8 <= len) {
long x = bb.getLong(pos);
long x = bb.getLong(ptr + pos);
if (skipChunk(x)) {
pos += 8;
continue;
Expand All @@ -48,7 +49,7 @@ void encode(ByteList src) throws IOException {
}

if (pos + 4 <= len) {
int x = bb.getInt(pos);
int x = bb.getInt(ptr + pos);
if (skipChunk(x)) {
pos += 4;
}
Expand Down
2 changes: 2 additions & 0 deletions test/json/json_encoding_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def test_generate_shared_string
# Ref: https://github.com/ruby/json/issues/859
s = "01234567890"
assert_equal '"234567890"', JSON.dump(s[2..-1])
s = '01234567890123456789"a"b"c"d"e"f"g"h'
assert_equal '"\"a\"b\"c\"d\"e\"f\"g\""', JSON.dump(s[20, 15])
end

def test_unicode
Expand Down