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
1 change: 1 addition & 0 deletions ext/json/ext/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,7 @@ static VALUE cResumableParser_parse(VALUE self)
{
JSON_ResumableParser *parser = ResumableParser_acquire(self, true);
if (!parser->buffer) {
parser->in_use = false;
return Qfalse;
}

Expand Down
15 changes: 15 additions & 0 deletions test/json/resumable_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ def test_clear
refute_predicate @parser, :value?
end

def test_parse_with_empty_buffer_keeps_parser_usable
# parse before any feed must not leak the in_use lock
refute @parser.parse
@parser << '[1, 2, 3]'
assert @parser.parse
assert_equal [1, 2, 3], @parser.value

# same after a clear with no following feed
@parser.clear
refute @parser.parse
@parser << '[4]'
assert @parser.parse
assert_equal [4], @parser.value
end

def test_parse_document_direct
@parser << '[true]'
assert_equal true, @parser.parse
Expand Down
Loading