Explorar o código

Handle out of memory when printing string

Max Bruckner %!s(int64=8) %!d(string=hai) anos
pai
achega
6622c54f18
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      cJSON.c

+ 4 - 1
cJSON.c

@@ -1452,7 +1452,10 @@ static char *print_object(const cJSON *item, int depth, cjbool fmt, printbuffer
             }
 
             /* print key */
-            print_string_ptr(child->string, p);
+            if (!print_string_ptr(child->string, p))
+            {
+                return NULL;
+            }
             p->offset = update(p);
 
             len = fmt ? 2 : 1;