if a malloc fails, clear up the memory and return failure
authorDaniel Stenberg <daniel@haxx.se>
Mon, 10 May 2004 14:04:06 +0000 (14:04 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 10 May 2004 14:04:06 +0000 (14:04 +0000)
lib/cookie.c

index 097a7d0..41f1401 100644 (file)
@@ -705,6 +705,16 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
              /* point the main to us */
              mainco = newco;
            }
+           else {
+              /* failure, clear up the allocated chain and return NULL */
+             while(mainco) {
+               co = mainco->next;
+               free(mainco);
+               mainco = co;
+             }
+
+             return NULL;
+           }
          }
        }
      }