Skip to content

Fix JSON::ResumableParser stalling on a NUL byte#1019

Merged
byroot merged 1 commit into
ruby:masterfrom
mame:fix-resumable-parser-nul
Jun 18, 2026
Merged

Fix JSON::ResumableParser stalling on a NUL byte#1019
byroot merged 1 commit into
ruby:masterfrom
mame:fix-resumable-parser-nul

Conversation

@mame

@mame mame commented Jun 18, 2026

Copy link
Copy Markdown
Member

Feeding "[\x00]" makes #parse return false forever and never make progress.

require "json"
parser = JSON::ResumableParser.new
parser << "[\x00]"
parser.parse   # => false
parser.parse   # => false
parser.parse   # => false (forever)

Fix: a NUL byte that is not at the end of the stream is treated as a syntax error (it can never become valid by feeding more), as the non-resumable parser already does.

Comment thread ext/json/ext/parser/parser.c Outdated
@byroot byroot force-pushed the fix-resumable-parser-nul branch from 9bb981f to f98367f Compare June 18, 2026 17:23
Co-Authored-By: Jean Boussier <jean.boussier@gmail.com>
@byroot byroot force-pushed the fix-resumable-parser-nul branch from f98367f to 31c948a Compare June 18, 2026 17:24
@byroot byroot merged commit d91b370 into ruby:master Jun 18, 2026
42 checks passed
@mame mame deleted the fix-resumable-parser-nul branch June 18, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants