소스 검색

check print_value return

Kyle Chisholm 8 년 전
부모
커밋
4d1dcaa160
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      cJSON.c

+ 5 - 3
cJSON.c

@@ -1154,8 +1154,7 @@ static char *print_array(const cJSON *item, int depth, cjbool fmt, printbuffer *
         child = item->child;
         while (child && !fail)
         {
-            ptr = print_value(child, depth + 1, fmt, p);
-            if (!ptr)
+            if (!print_value(child, depth + 1, fmt, p))
             {
                 return NULL;
             }
@@ -1472,7 +1471,10 @@ static char *print_object(const cJSON *item, int depth, cjbool fmt, printbuffer
             p->offset+=len;
 
             /* print value */
-            print_value(child, depth, fmt, p);
+            if (!print_value(child, depth, fmt, p))
+            {
+                return NULL;
+            };
             p->offset = update(p);
 
             /* print comma if not last */