Repository navigation
Display: validates --*-ndigits CLI options - #2772
Merged
CarterLi merged 1 commit intoNov 30, 2026
Merged
Conversation
`--size-ndigits` already rejected values outside 0..9, but `--temp-ndigits`, `--percent-ndigits`, `--fraction-ndigits`, and `--freq-ndigits` cast the parsed integer directly to `uint8_t`/`int8_t`. Values >= 16 hit `assert(precision <= 15)` in `ffStrbufAppendDouble` on debug builds or overflowed the 4-bit `YYJSON_WRITE_FP_TO_FIXED` field on release builds, and larger values wrapped modulo 256. Apply the same 0..9 and -1..9 checks used by `--size-ndigits` and JSON config parsing, and update the `--fraction-ndigits` remark in `doc/help.json` to match `-1`.
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.
Summary
--size-ndigitsrejects values outside0..9, while--temp-ndigits,--percent-ndigits,--fraction-ndigits, and--freq-ndigitsdon't check their range at all. They cast the parsed integer straight touint8_torint8_t. Passing 16 or higher hitsassert(precision <= 15)inffStrbufAppendDouble()on debug builds or overflows the 4-bitYYJSON_WRITE_FP_TO_FIXEDfield on release builds. Larger values like 128 or 256 silently wrap around.This adds the same
0..9/-1..9bounds checks to those four CLI flags, exiting 479 like--size-ndigitsand matching the JSON config parser. It also updates the--fraction-ndigitsremark indoc/help.jsonfrom "negative" to-1. Inputs that used to succeed now fail with an error:10..255for--temp-ndigitsand--percent-ndigits, plus10..15and values below-1for--fraction-ndigitsand--freq-ndigits.Before:
After:
Checklist