From 05355d3c7926e5f9b818d364db1666efabf8128a Mon Sep 17 00:00:00 2001 From: Ycros Date: Sat, 9 Jul 2011 16:10:35 +1000 Subject: [PATCH] Fix occasional crash when performing json rpc calls. --- util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index a0d8b5b9..8063d7d5 100644 --- a/util.c +++ b/util.c @@ -120,7 +120,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,10 @@ json_t *json_rpc_call(CURL *curl, const char *url, val = JSON_LOADS(all_data.buf, &err); if (!val) { applog(LOG_ERR, "JSON decode failed(%d): %s", err.line, err.text); + + if (opt_protocol) + applog(LOG_DEBUG, "JSON protocol response:\n%s", all_data.buf); + goto err_out; }