From: Bruno Haible Date: Sun, 21 Apr 2024 23:50:59 +0000 (+0200) Subject: Handle yet another out-of-memory condition. X-Git-Tag: json-c-0.18-20240915~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F861%2Fhead;p=thirdparty%2Fjson-c.git 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. --- 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) {