Handle empty responses properly
This commit is contained in:
parent
9ce0db5100
commit
80412755bd
1 changed files with 6 additions and 1 deletions
7
util.c
7
util.c
|
@ -118,7 +118,7 @@ static size_t all_data_cb(const void *ptr, size_t size, size_t nmemb,
|
|||
size_t len = size * nmemb;
|
||||
size_t oldlen, newlen;
|
||||
void *newmem;
|
||||
static const unsigned char zero;
|
||||
static const unsigned char zero = 0;
|
||||
|
||||
oldlen = db->len;
|
||||
newlen = oldlen + len;
|
||||
|
@ -284,6 +284,11 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
|||
free(hi.lp_path);
|
||||
hi.lp_path = NULL;
|
||||
|
||||
if (!all_data.buf) {
|
||||
applog(LOG_ERR, "Empty data received in json_rpc_call.");
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
val = JSON_LOADS(all_data.buf, &err);
|
||||
if (!val) {
|
||||
applog(LOG_ERR, "JSON decode failed(%d): %s", err.line, err.text);
|
||||
|
|
Loading…
Reference in a new issue