From fcc89c4bb264d665929b00eeebc479a643a90896 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Thu, 15 Dec 2016 11:12:07 +0100 Subject: [PATCH] Move increment out of loop condition fixes #85 --- cJSON.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index a409c8d..d20341a 100644 --- a/cJSON.c +++ b/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. */