diff options
| author | Andre Heinecke <[email protected]> | 2018-07-16 17:47:11 +0000 | 
|---|---|---|
| committer | Andre Heinecke <[email protected]> | 2018-07-16 17:47:11 +0000 | 
| commit | 1686e07e77a1eee3b2708d0231a5a549956021f7 (patch) | |
| tree | 1a545510aea6be22b83d5f2d7ed734fc91fcb846 /src/gpgme-json.c | |
| parent | json: Fix uninitialized key unref in op_delete (diff) | |
| download | gpgme-1686e07e77a1eee3b2708d0231a5a549956021f7.tar.gz gpgme-1686e07e77a1eee3b2708d0231a5a549956021f7.zip  | |
json: Fix crash on invalid json
* src/gpgme-json.c (process_request): Init res. Check for
json object before encode and chunk.
--
If json is invalid we can't read chunksize and would crash
in encode and chunk.
Diffstat (limited to 'src/gpgme-json.c')
| -rw-r--r-- | src/gpgme-json.c | 4 | 
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gpgme-json.c b/src/gpgme-json.c index 0aeb7f91..06f09ef0 100644 --- a/src/gpgme-json.c +++ b/src/gpgme-json.c @@ -3104,7 +3104,7 @@ process_request (const char *request)    int helpmode;    int is_getmore = 0;    const char *op; -  char *res; +  char *res = NULL;    int idx;    response = xjson_CreateObject (); @@ -3188,7 +3188,7 @@ process_request (const char *request)        else          res = cJSON_PrintUnformatted (response);      } -  else +  else if (json)      res = encode_and_chunk (json, response);    if (!res)      log_error ("Printing JSON data failed\n");  | 
