Skip to content

Commit c331688

Browse files
gnl21charles-lunarg
authored andcommitted
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.
1 parent ce2d68b commit c331688

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

loader/cJSON.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ static unsigned char *print(const cJSON *const item, cJSON_bool format, bool *ou
914914
buffer->format = format;
915915
buffer->pAllocator = item->pAllocator;
916916
if (buffer->buffer == NULL) {
917+
*out_of_memory = true;
917918
goto fail;
918919
}
919920

0 commit comments

Comments
 (0)