]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: better cleanup of easy handle in exit path
authorxkernel <xkernel.wang@foxmail.com>
Sun, 10 Jul 2022 16:23:03 +0000 (18:23 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 10 Jul 2022 16:23:03 +0000 (18:23 +0200)
Closes #9114

src/tool_operate.c

index 133d5b1915cfd3f47510942e492dacfdce6f9851..fe4237cbb43cdc61f564741f34305ccfaee04aca 100644 (file)
@@ -2471,8 +2471,10 @@ static CURLcode transfer_per_config(struct GlobalConfig *global,
      */
     result = curl_easy_getinfo(curltls, CURLINFO_TLS_SSL_PTR,
                                &tls_backend_info);
-    if(result)
+    if(result) {
+      curl_easy_cleanup(curltls);
       return result;
+    }
 
     /* Set the CA cert locations specified in the environment. For Windows if
      * no environment-specified filename is found then check for CA bundle
@@ -2489,6 +2491,7 @@ static CURLcode transfer_per_config(struct GlobalConfig *global,
         config->cacert = strdup(env);
         if(!config->cacert) {
           curl_free(env);
+          curl_easy_cleanup(curltls);
           errorf(global, "out of memory\n");
           return CURLE_OUT_OF_MEMORY;
         }
@@ -2499,6 +2502,7 @@ static CURLcode transfer_per_config(struct GlobalConfig *global,
           config->capath = strdup(env);
           if(!config->capath) {
             curl_free(env);
+            curl_easy_cleanup(curltls);
             helpf(global->errors, "out of memory\n");
             return CURLE_OUT_OF_MEMORY;
           }
@@ -2510,6 +2514,7 @@ static CURLcode transfer_per_config(struct GlobalConfig *global,
             config->cacert = strdup(env);
             if(!config->cacert) {
               curl_free(env);
+              curl_easy_cleanup(curltls);
               errorf(global, "out of memory\n");
               return CURLE_OUT_OF_MEMORY;
             }