require ALLOW_HEX for hex integers in StringToIeee - #321
Merged
Merged
Conversation
floitsch
enabled auto-merge (squash)
September 27, 2026 23:33
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.
Repro: with ALLOW_HEX_FLOATS alone, StringToDouble("0x12") returns 18 and "0X1A" returns 26 with every character processed; with ALLOW_TRAILING_JUNK added, "0x12z" and "0x12p" return 18. The header lets only ALLOW_HEX introduce hex integers and requires a 'p' exponent for a hex-float, and with no hex flag set the same inputs are junk_string_value.
Cause: StringToIeee treats "0x" as a hex prefix when either flag is set, and when IsHexFloatString rejects the literal it falls through to the hex-integer parse checking only that the next character is a hex digit, never that ALLOW_HEX is set.
Fix: return junk_string_value in that fall-through unless ALLOW_HEX is set. ALLOW_HEX behaviour and hex-float parsing are unchanged; regression checks sit in the ALLOW_HEX_FLOATS-only blocks of StringToDoubleHexString and StringToFloatHexString.
Master's Debug ci job already aborts in test_bignum and test_dtoa (the #318 tests pass -1 to MultiplyByPowerOfTen, AssignPowerUInt16 and DoubleToAscii, which still assert); that is unrelated to this change.