Skip to content

require ALLOW_HEX for hex integers in StringToIeee - #321

Merged
floitsch merged 1 commit into
google:masterfrom
Ramya-9353:hex-int-needs-allow-hex
Sep 27, 2026
Merged

floitsch merged 1 commit into
google:masterfrom
Ramya-9353:hex-int-needs-allow-hex

Conversation

@Ramya-9353

Copy link
Copy Markdown
Contributor

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.

@floitsch floitsch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@floitsch
floitsch enabled auto-merge (squash) September 27, 2026 23:33
@floitsch
floitsch merged commit d64160a into google:master Sep 27, 2026
9 checks passed
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