From: Daniel Stenberg Date: Mon, 10 May 2004 14:04:06 +0000 (+0000) Subject: if a malloc fails, clear up the memory and return failure X-Git-Tag: curl-7_12_0~144 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5dcab07c542b9365f59e859da578dfea0c6014b5;p=curl if a malloc fails, clear up the memory and return failure --- diff --git a/lib/cookie.c b/lib/cookie.c index 097a7d03b..41f14011f 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -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; + } } } }