From dc4b62915ac9357405c2297f538c6f56e491d040 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Mon, 14 Nov 2016 19:33:03 +0700 Subject: [PATCH] fix #10, now failing on incorrect escape sequences --- cJSON.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cJSON.c b/cJSON.c index 06d2cb8..00875c5 100644 --- a/cJSON.c +++ b/cJSON.c @@ -534,6 +534,11 @@ static const char *parse_string(cJSON *item, const char *str, const char **ep) case 't': *ptr2++ = '\t'; break; + case '\"': + case '\\': + case '/': + *ptr2++ = *ptr; + break; case 'u': /* transcode utf16 to utf8. See RFC2781 and RFC3629. */ uc = parse_hex4(ptr + 1); /* get the unicode char. */ @@ -620,8 +625,8 @@ static const char *parse_string(cJSON *item, const char *str, const char **ep) ptr2 += len; break; default: - *ptr2++ = *ptr; - break; + *ep = str; + return 0; } ptr++; }