1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 17:18:48 -05:00

curl/parseconfig: fix mem-leak

When looping, first trying '.curlrc' and then '_curlrc', the function
would not free the first string.

Closes #4731
This commit is contained in:
Daniel Stenberg 2019-12-18 13:30:39 +01:00
parent 14f8b6e69e
commit f098c9e6f6
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

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