Parse nan in JSON as NaN instead of triggering a parse error (#2712)

* Fix memory leak for has(nan)

jv_array_get() used to be responsible of freeing the input array, but
since b5c4c3d67d, it is no longer called
if the key is nan. We need to free it manually to avoid leaking the
array.

* Parse  nan  in JSON as NaN instead of triggering a parse error

Fixes #2021
This commit is contained in:
Emanuele Torre authored and GitHub committed 2023-07-14 07:12:27 +09:00
1 parent 092fef740a
commit 4b1ac7c95f
3 files changed
+18 -1

No files matched your search

+12
View File
@@ -1799,6 +1799,18 @@ reduce .[] as $then (4 as $else | $else; . as $elif | . + $then * $elif)
# { $__loc__ } works
{ a, $__loc__, c }
{"a":[1,2,3],"b":"foo","c":{"hi":"hey"}}
{"a":[1,2,3],"__loc__":{"file":"<top-level>","line":1},"c":{"hi":"hey"}}
# nan is parsed as a valid NaN value from JSON
fromjson | isnan
"nan"
true
tojson | fromjson
{"a":nan}
{"a":null}