gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnurl] 118/151: curl: fix memory leak in OOM in etags logic


From: gnunet
Subject: [gnurl] 118/151: curl: fix memory leak in OOM in etags logic
Date: Fri, 20 Dec 2019 14:27:07 +0100

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnurl.

commit 70a654151515a3cd17b47884154b34a857e81db9
Author: Daniel Stenberg <address@hidden>
AuthorDate: Thu Dec 12 10:38:14 2019 +0100

    curl: fix memory leak in OOM in etags logic
    
    Detected by torture tests
    
    Closes #4706
---
 src/tool_operate.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/tool_operate.c b/src/tool_operate.c
index bbd7fa49d..d4f170e33 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -926,25 +926,25 @@ static CURLcode single_transfer(struct GlobalConfig 
*global,
           /* open file for reading: */
           FILE *file = fopen(config->etag_compare_file, FOPEN_READTEXT);
           if(!file) {
-            warnf(
-              config->global,
-              "Failed to open %s\n", config->etag_compare_file);
-
+            errorf(config->global,
+                   "Failed to open %s\n", config->etag_compare_file);
             result = CURLE_READ_ERROR;
             break;
           }
 
           if((PARAM_OK == file2string(&etag_from_file, file)) &&
-             etag_from_file)
+             etag_from_file) {
             header = aprintf("If-None-Match: \"%s\"", etag_from_file);
+            Curl_safefree(etag_from_file);
+          }
           else
             header = aprintf("If-None-Match: \"\"");
 
           if(!header) {
-            warnf(
-              config->global,
-              "Failed to allocate memory for custom etag header\n");
-
+            if(file)
+              fclose(file);
+            errorf(config->global,
+                   "Failed to allocate memory for custom etag header\n");
             result = CURLE_OUT_OF_MEMORY;
             break;
           }
@@ -953,7 +953,6 @@ static CURLcode single_transfer(struct GlobalConfig *global,
           add2list(&config->headers, header);
 
           Curl_safefree(header);
-          Curl_safefree(etag_from_file);
 
           if(file) {
             fclose(file);

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]