]> granicus.if.org Git - curl/commitdiff
win32: fix a potential memory leak in Curl_load_library
authorMartin Vejnár <martin.vejnar@avg.com>
Mon, 1 Aug 2016 08:18:55 +0000 (10:18 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 1 Aug 2016 08:43:10 +0000 (10:43 +0200)
If a call to GetSystemDirectory fails, the `path` pointer that was
previously allocated would be leaked. This makes sure that `path` is
always freed.

Closes #938

lib/system_win32.c

index 2ba7d0bc1c2198e167943ebbe5e50d976ed709ee..d6a998b275c685df9b0b68eab47150347ffd190a 100644 (file)
@@ -281,8 +281,8 @@ HMODULE Curl_load_library(LPCTSTR filename)
           pLoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) :
           LoadLibrary(path);
 
-        free(path);
       }
+      free(path);
     }
   }