]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl/parseconfig: fix mem-leak
authorDaniel Stenberg <daniel@haxx.se>
Wed, 18 Dec 2019 12:30:39 +0000 (13:30 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 18 Dec 2019 13:48:32 +0000 (14:48 +0100)
When looping, first trying '.curlrc' and then '_curlrc', the function
would not free the first string.

Closes #4731

src/tool_parsecfg.c

index 9b32e54a02d6afc419dc2504d67d571153ab394f..208897f48c1ca047a4337e30904cd5d0475e5fa9 100644 (file)
@@ -97,6 +97,8 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
       int i = 0;
       char prefix = '.';
       do {
+        /* if it was allocated in a previous attempt */
+        free(pathalloc);
         /* check for .curlrc then _curlrc in the home dir */
         pathalloc = curl_maprintf("%s%s%ccurlrc", home, DIR_CHAR, prefix);
         if(!pathalloc) {