]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_xml_curl] Coverity CID 1468413 (Resource leak) 2031/head
authorJakub Karolczyk <jakub.karolczyk@signalwire.com>
Thu, 6 Apr 2023 00:30:38 +0000 (01:30 +0100)
committerJakub Karolczyk <jakub.karolczyk@signalwire.com>
Thu, 6 Apr 2023 17:27:42 +0000 (18:27 +0100)
src/mod/xml_int/mod_xml_curl/mod_xml_curl.c

index 6a8f2aac53922aa42b41616982d124a83a53c43f..67181e26c49a06faf110a0be224f8bec6812ba08 100644 (file)
@@ -210,13 +210,6 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
        switch_uuid_format(uuid_str, &uuid);
 
        switch_snprintf(filename, sizeof(filename), "%s%s%s.tmp.xml", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str);
-       curl_handle = switch_curl_easy_init();
-       headers = switch_curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
-
-       if (!strncasecmp(binding->url, "https", 5)) {
-               switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
-               switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
-       }
 
        memset(&config_data, 0, sizeof(config_data));
 
@@ -224,6 +217,14 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
        config_data.max_bytes = binding->curl_max_bytes;
 
        if ((config_data.fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
+               curl_handle = switch_curl_easy_init();
+               headers = switch_curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
+
+               if (!strncasecmp(binding->url, "https", 5)) {
+                       switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
+                       switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
+               }
+
                if (!zstr(binding->cred)) {
                        switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, binding->auth_scheme);
                        switch_curl_easy_setopt(curl_handle, CURLOPT_USERPWD, binding->cred);