浏览代码

Move increment out of loop condition fixes #85

Max Bruckner 8 年之前
父节点
当前提交
fcc89c4bb2
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      cJSON.c

+ 2 - 1
cJSON.c

@@ -491,7 +491,7 @@ static const char *parse_string(cJSON *item, const char *str, const char **ep)
         return NULL;
     }
 
-    while ((*end_ptr != '\"') && *end_ptr && ++len)
+    while ((*end_ptr != '\"') && *end_ptr)
     {
         if (*end_ptr++ == '\\')
         {
@@ -503,6 +503,7 @@ static const char *parse_string(cJSON *item, const char *str, const char **ep)
             /* Skip escaped quotes. */
             end_ptr++;
         }
+        len++;
     }
 
     /* This is at most how long we need for the string, roughly. */