fix: avoid pointer underflow for empty input#4
Merged
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds an explicit empty-input guard to the C++ allocator function and introduces a test case validating that decoding an empty JSON string produces an error with an "EMPTY" marker in the message. ChangesEmpty Input Validation
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Actionable comments posted: 0 |
nic-6443
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a small undefined-behavior edge case in the padding check for empty input.
need_allocation()computedbuf + len - 1unconditionally. Whenlen == 0, that forms a pointer before the start of the input buffer before simdjson can return the normalEMPTYparse error. The runtime behavior is benign in normal builds, but the pointer arithmetic itself is undefined C++ behavior.This change forces allocation for zero-length input before doing the end-of-buffer page check. The observable decode behavior stays the same: empty input returns
simdjson: error: EMPTY: no JSON found.Validation:
Summary by CodeRabbit
Bug Fixes
Tests