diff --git a/backport-fix-print-int-without-decimal-places-630.patch b/backport-fix-print-int-without-decimal-places-630.patch new file mode 100644 index 0000000000000000000000000000000000000000..d87b70c9fb8467656ec31e5f1993fdfbac054c32 --- /dev/null +++ b/backport-fix-print-int-without-decimal-places-630.patch @@ -0,0 +1,26 @@ +From d321fa9e6e574ff93518f6384865b9af0a4a4afc Mon Sep 17 00:00:00 2001 +From: AlexanderVasiljev <48011002+AlexanderVasiljev@users.noreply.github.com> +Date: Wed, 19 Jan 2022 05:30:31 +0300 +Subject: [PATCH] fix: print int without decimal places (#630) + +--- + cJSON.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/cJSON.c b/cJSON.c +index 3063f74..c78aac6 100644 +--- a/cJSON.c ++++ b/cJSON.c +@@ -562,6 +562,10 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out + { + length = sprintf((char*)number_buffer, "null"); + } ++ else if(d == (double)item->valueint) ++ { ++ length = sprintf((char*)number_buffer, "%d", item->valueint); ++ } + else + { + /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ +-- + diff --git a/cjson.spec b/cjson.spec index 95bb4c8160fe9c7932a5099833cf867643afb367..07d0f90f113fdac0f2bc9c4a74b6c5032ed0f519 100644 --- a/cjson.spec +++ b/cjson.spec @@ -1,6 +1,6 @@ Name: cjson Version: 1.7.15 -Release: 6 +Release: 7 Summary: Ultralightweight JSON parser in ANSI C License: MIT and ASL 2.0 @@ -10,8 +10,9 @@ Source0: https://github.com/DaveGamble/cJSON/archive/refs/tags/v1.7.15.ta Patch0001: backport-CVE-2023-50471_50472.patch Patch0002: backport-fix-potential-memory-leak-in-merge_patch.patch Patch0003: CVE-2024-31755.patch -Patch0004: Fix-a-null-pointer-crash-in-cJSON_ReplaceItemViaPoin.patch -Patch0005: backport-fix-add-allocate-check-for-replace_item_in_object-67.patch +Patch0004: Fix-a-null-pointer-crash-in-cJSON_ReplaceItemViaPoin.patch +Patch0005: backport-fix-add-allocate-check-for-replace_item_in_object-67.patch +Patch0006: backport-fix-print-int-without-decimal-places-630.patch BuildRequires: gcc BuildRequires: cmake @@ -58,6 +59,9 @@ rm -f %{buildroot}%{_libdir}/cmake/cJSON/*.cmake %{_includedir}/cjson/ %changelog +* Fri May 10 2024 wuzhaomin - 1.7.15-7 +- Fix print int without decimal places + * Wed May 8 2024 wuzhaomin - 1.7.15-6 - add allocate check for replace_item_in_object