Set error=json_tokener_error_memory in json_tokener_parser_verbose() when allocating the tokener fails

This commit is contained in:
肖在 2024-05-16 15:46:50 +08:00
parent 9aa8f7484e
commit e77c752ae0
2 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,28 @@
From e93ae70417867dac9ff87614f3e7bc50e79ef951 Mon Sep 17 00:00:00 2001
From: Eric Hawicz <erh+git@nimenees.com>
Date: Fri, 29 Mar 2024 18:09:12 -0400
Subject: [PATCH 093/100] Fix issue #854: Set error=json_tokener_error_memory
in json_tokener_parser_verbose() when allocating the tokener fails.
---
json_tokener.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/json_tokener.c b/json_tokener.c
index 9926563..e8244a3 100644
--- a/json_tokener.c
+++ b/json_tokener.c
@@ -226,7 +226,10 @@ struct json_object *json_tokener_parse_verbose(const char *str, enum json_tokene
tok = json_tokener_new();
if (!tok)
+ {
+ *error = json_tokener_error_memory;
return NULL;
+ }
obj = json_tokener_parse_ex(tok, str, -1);
*error = tok->err;
if (tok->err != json_tokener_success
--
2.33.0

View File

@ -6,7 +6,7 @@
Name: json-c Name: json-c
Version: 0.17 Version: 0.17
Release: 1 Release: 2
Summary: JSON implementation in C Summary: JSON implementation in C
License: MIT License: MIT
@ -15,6 +15,8 @@ Source0: %{url}/archive/%{name}-%{version}-%{reldate}.tar.gz
BuildRequires: cmake gcc ninja-build BuildRequires: cmake gcc ninja-build
Patch001: backport-fix-issue-854-Set-error-json_tokener_error_memory-in.patch
%description %description
JSON-C implements a reference counting object model that allows you JSON-C implements a reference counting object model that allows you
to easily construct JSON objects in C, output them as JSON formatted to easily construct JSON objects in C, output them as JSON formatted
@ -101,6 +103,9 @@ end
%doc %{_pkgdocdir} %doc %{_pkgdocdir}
%changelog %changelog
* Thu May 16 2024 xiaozai <xiaozai@kylinos.cn> - 0.17-2
- add backport-fix-issue-854-Set-error-json_tokener_error_memory-in.patch
* Wed Aug 16 2023 dillon chen <dillon.chen@gmail.com> - 0.17-1 * Wed Aug 16 2023 dillon chen <dillon.chen@gmail.com> - 0.17-1
- Update to 0.17 - Update to 0.17