|
| 1 | +From b5403362c386b80e4726f52897c5fe5d3705a9a6 Mon Sep 17 00:00:00 2001 |
| 2 | +From: AllSpark <allspark@microsoft.com> |
| 3 | +Date: Wed, 29 Oct 2025 05:38:18 +0000 |
| 4 | +Subject: [PATCH] Fix expected value assertion for NaN value (fix #3393): - |
| 5 | + Include math.h for isnan - Skip reparsing/roundtrip assertion when expected |
| 6 | + is NaN under USE_DECNUM |
| 7 | + |
| 8 | +Signed-off-by: Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> |
| 9 | +Upstream-reference: AI Backport of https://github.com/jqlang/jq/commit/304a0f7e0ec376bf0ecabf9f96b2ab3432548819.patch |
| 10 | +--- |
| 11 | + src/jq_test.c | 13 ++++++++----- |
| 12 | + 1 file changed, 8 insertions(+), 5 deletions(-) |
| 13 | + |
| 14 | +diff --git a/src/jq_test.c b/src/jq_test.c |
| 15 | +index 7a396b9..0172a76 100644 |
| 16 | +--- a/src/jq_test.c |
| 17 | ++++ b/src/jq_test.c |
| 18 | +@@ -2,6 +2,7 @@ |
| 19 | + #include <stdio.h> |
| 20 | + #include <string.h> |
| 21 | + #include <stdlib.h> |
| 22 | ++#include <math.h> |
| 23 | + #include "jv.h" |
| 24 | + #include "jq.h" |
| 25 | + |
| 26 | +@@ -157,11 +158,13 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata) { |
| 27 | + printf(" for test at line number %u: %s\n", lineno, prog); |
| 28 | + pass = 0; |
| 29 | + } |
| 30 | +- jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT)); |
| 31 | +- jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string))); |
| 32 | +- assert(jv_equal(jv_copy(expected), jv_copy(reparsed))); |
| 33 | +- jv_free(as_string); |
| 34 | +- jv_free(reparsed); |
| 35 | ++ if (!(jv_get_kind(expected) == JV_KIND_NUMBER && isnan(jv_number_value(expected)))) { |
| 36 | ++ jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT)); |
| 37 | ++ jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string))); |
| 38 | ++ assert(jv_equal(jv_copy(expected), jv_copy(reparsed))); |
| 39 | ++ jv_free(as_string); |
| 40 | ++ jv_free(reparsed); |
| 41 | ++ } |
| 42 | + jv_free(expected); |
| 43 | + jv_free(actual); |
| 44 | + } |
| 45 | +-- |
| 46 | +2.45.4 |
| 47 | + |
0 commit comments