From 2688cf343bdcab56c781e1932c42aadea7bacb39 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Sun, 19 Oct 2008 21:00:40 +0000
Subject: [PATCH] Fixed potential memory leak in OOM situations. Detected by
 coverity.com

---
 src/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index 8212c028f6..3c248a5810 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2313,6 +2313,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
           }
           else {
             char *enc = curl_easy_escape(config->easy, postdata, size);
+            free(postdata); /* no matter if it worked or not */
             if(enc) {
               /* now make a string with the name from above and append the
                  encoded string */
@@ -2325,7 +2326,6 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
               else
                 strcpy(n, enc);
               curl_free(enc);
-              free(postdata);
               if(n) {
                 postdata = n;
               }
-- 
GitLab