diff --git a/lib/cookie.c b/lib/cookie.c index 097a7d03b4f04ba2469642e6802d8f1ea9b11f4f..41f14011ff7b095e536a9fe9f35101dd3dc6b1b1 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; + } } } }