diff options
| author | Andre Heinecke <[email protected]> | 2018-08-08 11:30:01 +0000 | 
|---|---|---|
| committer | Andre Heinecke <[email protected]> | 2018-08-08 11:30:01 +0000 | 
| commit | 974a95db04f9cdea02867f0246445b4679517ba0 (patch) | |
| tree | 7a9845ec7a61eee72203cc6a9e7079e4206bc882 /src | |
| parent | json: Don't error out if chunksize is omitted (diff) | |
| download | gpgme-974a95db04f9cdea02867f0246445b4679517ba0.tar.gz gpgme-974a95db04f9cdea02867f0246445b4679517ba0.zip | |
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 '')
| -rw-r--r-- | src/cJSON.c | 10 | 
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.  */ | 
