summaryrefslogtreecommitdiff
path: root/src/cJSON.c
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2018-08-08 13:30:01 +0200
committerAndre Heinecke <aheinecke@intevation.de>2018-08-08 13:30:01 +0200
commit974a95db04f9cdea02867f0246445b4679517ba0 (patch)
tree7a9845ec7a61eee72203cc6a9e7079e4206bc882 /src/cJSON.c
parent6e48bb0f1cbf662026bf0f70549b52bafe00c017 (diff)
downloadgpgme-974a95db04f9cdea02867f0246445b4679517ba0.tar.gz
json: Add checks when skipping byte
* src/cJSON.c (parse_string, cJSON_Minify): Check for terminating NULL byte when skipping the byte after a an escaped quote.
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. */