]> granicus.if.org Git - curl/commitdiff
url.c: fix parse_login_details() OOM handling
authorYang Tse <yangsita@gmail.com>
Fri, 12 Jul 2013 10:16:48 +0000 (12:16 +0200)
committerYang Tse <yangsita@gmail.com>
Fri, 12 Jul 2013 10:17:31 +0000 (12:17 +0200)
lib/url.c

index a9760631d6fc57e1f07785eabd77f90a10f994d9..6addc2677926e3ddd9071399293e3993f0ec4bc1 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -4565,15 +4565,20 @@ static CURLcode parse_login_details(const char *login, const size_t len,
   /* Allocate the password portion buffer */
   if(!result && passwdp && plen) {
     pbuf = malloc(plen + 1);
-    if(!pbuf)
+    if(!pbuf) {
+      Curl_safefree(ubuf);
       result = CURLE_OUT_OF_MEMORY;
+    }
   }
 
   /* Allocate the options portion buffer */
   if(!result && optionsp && olen) {
     obuf = malloc(olen + 1);
-    if(!obuf)
+    if(!obuf) {
+      Curl_safefree(pbuf);
+      Curl_safefree(ubuf);
       result = CURLE_OUT_OF_MEMORY;
+    }
   }
 
   if(!result) {