Repository navigation
Conversation
With an empty infinity_symbol or nan_symbol, an input character '\0' matched the symbol's first character (its terminator), and ConsumeSubString then stepped past the terminator and compared the following input with whatever memory came after the symbol. Treat an empty symbol as never matching.
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.
The string-to-double converter accepts
NULLforinfinity_symbol/nan_symbolto disable them, but an empty string""is also accepted. With an empty symbol, an input whose first character (after the sign) is'\0'matches the symbol's first character, which is its terminator.ConsumeSubStringthen advances past that terminator and keeps comparing the following input with whatever bytes come after the symbol in memory.Effects, for inputs with an embedded NUL (the input is length-delimited, so this is possible):
ConsumeSubStringwhen the symbol is a 1-byte heap allocation);Infinity/NaN. For example, with the symbol stored as{'\0', 'x', '\0'}, the input{'\0', 'x'}returnsinfwithprocessed == 2.This change makes
ConsumeFirstCharacterreturn false for an empty symbol, so an empty symbol never matches, likeNULL. Non-empty symbols are unaffected.Test: a new
EmptySpecialValueSymbolscase intest/cctest/test-conversions.cccovers an empty infinity symbol and an empty NaN symbol,charanduc16input, a leading sign, the case-insensitive path andStringToFloat, and checks that the other symbol and ordinary numbers still parse. On master it fails withExpected: 1.0, Found: inf; with this change it passes.ctest(9/9) passes in a Debug build with-fsanitize=address,undefined.This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.