32 lines
904 B
Diff
32 lines
904 B
Diff
|
|
From 833233faa8d6835276ebbd48b92c7feeb141270d Mon Sep 17 00:00:00 2001
|
||
|
|
From: Bruno Haible <bruno@clisp.org>
|
||
|
|
Date: Mon, 22 Apr 2024 01:50:59 +0200
|
||
|
|
Subject: [PATCH] Handle yet another out-of-memory condition.
|
||
|
|
|
||
|
|
duplocale() can return NULL, with errno set to ENOMEM.
|
||
|
|
In this case, bail out and set the current error code to
|
||
|
|
json_tokener_error_memory.
|
||
|
|
---
|
||
|
|
json_tokener.c | 5 +++++
|
||
|
|
1 file changed, 5 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/json_tokener.c b/json_tokener.c
|
||
|
|
index cc35527..0a86d82 100644
|
||
|
|
--- a/json_tokener.c
|
||
|
|
+++ b/json_tokener.c
|
||
|
|
@@ -341,6 +341,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
|
||
|
|
#ifdef HAVE_USELOCALE
|
||
|
|
{
|
||
|
|
locale_t duploc = duplocale(oldlocale);
|
||
|
|
+ if (duploc == NULL && errno == ENOMEM)
|
||
|
|
+ {
|
||
|
|
+ tok->err = json_tokener_error_memory;
|
||
|
|
+ return NULL;
|
||
|
|
+ }
|
||
|
|
newloc = newlocale(LC_NUMERIC_MASK, "C", duploc);
|
||
|
|
if (newloc == NULL)
|
||
|
|
{
|
||
|
|
--
|
||
|
|
2.43.4
|
||
|
|
|