Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jv_parse: let decNumberFromString/strtod parse complex nans as a NaN #2985

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/jv_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ static pfunc check_literal(struct jv_parser* p) {
case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
case 'n':
// if it starts with 'n', it could be a literal "nan"
if (p->tokenpos != 3) {
if (p->tokenbuf[1] == 'u') {
emanuele6 marked this conversation as resolved.
Show resolved Hide resolved
pattern = "null"; plen = 4; v = jv_null();
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/jq.test
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,11 @@ tojson | fromjson
{"a":nan}
{"a":null}

# also "nan with payload" #2985
fromjson | isnan
"nan1234"
true


# calling input/0, or debug/0 in a test doesn't crash jq

Expand Down