From b7e45396b70ab5ebc74966686079cbf8448acfe4 Mon Sep 17 00:00:00 2001 From: Graeme Leese Date: Tue, 3 Dec 2024 15:00:41 +0000 Subject: [PATCH] Fix out-of-memory case in cJSON If the initial calloc failed then NULL was being returned but the out_of_memory flag was not being set, so callers did not understand the returned value correctly. Set the flag. --- loader/cJSON.c | 1 + 1 file changed, 1 insertion(+) diff --git a/loader/cJSON.c b/loader/cJSON.c index 54062c3cb..da4ba8519 100644 --- a/loader/cJSON.c +++ b/loader/cJSON.c @@ -914,6 +914,7 @@ static unsigned char *print(const cJSON *const item, cJSON_bool format, bool *ou buffer->format = format; buffer->pAllocator = item->pAllocator; if (buffer->buffer == NULL) { + *out_of_memory = true; goto fail; }