if a malloc fails, clear up the memory and return failure

This commit is contained in:
Daniel Stenberg
2004-05-10 14:04:06 +00:00
parent 1f798affb9
commit 5dcab07c54

View 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;
}
}
}
}