Skip to content

Commit

Permalink
Fix out-of-memory case in cJSON
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gnl21 committed Dec 3, 2024
1 parent ce2d68b commit b7e4539
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions loader/cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b7e4539

Please sign in to comment.