From 5dcab07c542b9365f59e859da578dfea0c6014b5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 10 May 2004 14:04:06 +0000 Subject: if a malloc fails, clear up the memory and return failure --- lib/cookie.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') 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; + } } } } -- cgit v1.2.3