aboutsummaryrefslogtreecommitdiffstats
path: root/src/cJSON.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cJSON.c')
-rw-r--r--src/cJSON.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cJSON.c b/src/cJSON.c
index 65d105ba..eea1adf0 100644
--- a/src/cJSON.c
+++ b/src/cJSON.c
@@ -249,7 +249,7 @@ parse_string (cJSON * item, const char *str, const char **ep)
} /* not a string! */
while (*ptr != '\"' && *ptr && ++len)
- if (*ptr++ == '\\')
+ if (*ptr++ == '\\' && *ptr)
ptr++; /* Skip escaped quotes. */
out = xtrymalloc (len + 2); /* This is how long we need for the
@@ -268,6 +268,8 @@ parse_string (cJSON * item, const char *str, const char **ep)
else
{
ptr++;
+ if (!*ptr)
+ break;
switch (*ptr)
{
case 'b':
@@ -1416,9 +1418,11 @@ cJSON_Minify (char *json)
{
if (*json == '\\')
*into++ = *json++;
- *into++ = *json++;
+ if (*json)
+ *into++ = *json++;
}
- *into++ = *json++;
+ if (*json)
+ *into++ = *json++;
} /* String literals, which are \" sensitive. */
else
*into++ = *json++; /* All other characters. */