From: Rainer Müller Date: Sun, 10 Nov 2013 02:39:22 +0000 (+0100) Subject: curl_json, curl_xml: Fix unitialized variable X-Git-Tag: collectd-5.4.1~5 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=8327ee64;p=collectd.git curl_json, curl_xml: Fix unitialized variable The variable url is used unintialized here. The code used to be the same in both plugins, but diverged in 19808b44. The solution applied there does not work correctly as the effective URL can only be queried after performing the request. Instead, just use the original request URL. Signed-off-by: Florian Forster --- diff --git a/src/curl_json.c b/src/curl_json.c index 511863e3..6c7cf8d8 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -859,17 +859,17 @@ static int cj_curl_perform(cj_t *db) /* {{{ */ int status; long rc; char *url; - url = NULL; - curl_easy_getinfo(db->curl, CURLINFO_EFFECTIVE_URL, &url); + url = db->url; status = curl_easy_perform (db->curl); if (status != CURLE_OK) { ERROR ("curl_json plugin: curl_easy_perform failed with status %i: %s (%s)", - status, db->curl_errbuf, (url != NULL) ? url : ""); + status, db->curl_errbuf, url); return (-1); } + curl_easy_getinfo(db->curl, CURLINFO_EFFECTIVE_URL, &url); curl_easy_getinfo(db->curl, CURLINFO_RESPONSE_CODE, &rc); /* The response code is zero if a non-HTTP transport was used. */ diff --git a/src/curl_xml.c b/src/curl_xml.c index 5adaf067..5d14a1d9 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -608,6 +608,7 @@ static int cx_curl_perform (cx_t *db, CURL *curl) /* {{{ */ long rc; char *ptr; char *url; + url = db->url; db->buffer_fill = 0; status = curl_easy_perform (curl);