1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-11 12:05:06 -05:00

fix out of memory handling issue

This commit is contained in:
Yang Tse 2007-04-07 04:51:35 +00:00
parent 47594be5c0
commit d9e89e170f
2 changed files with 18 additions and 4 deletions

View File

@ -1005,13 +1005,18 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data)
/* fill the list with _all_ the cookies we know */ /* fill the list with _all_ the cookies we know */
line = get_netscape_format(c); line = get_netscape_format(c);
if (line == NULL) { if (line == NULL) {
/* get_netscape_format returns null only if we run out of memory */ curl_slist_free_all(beg);
curl_slist_free_all(beg); /* free some memory */
return NULL; return NULL;
} }
list = curl_slist_append(list, line); list = curl_slist_append(list, line);
free(line); free(line);
if (list == NULL) {
curl_slist_free_all(beg);
return NULL;
}
else if (beg == NULL) {
beg = list;
}
c = c->next; c = c->next;
} }

View File

@ -678,10 +678,19 @@ struct curl_slist *Curl_ossl_engines_list(struct SessionHandle *data)
{ {
struct curl_slist *list = NULL; struct curl_slist *list = NULL;
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H) #if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
struct curl_slist *beg = NULL;
ENGINE *e; ENGINE *e;
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) {
list = curl_slist_append(list, ENGINE_get_id(e)); list = curl_slist_append(list, ENGINE_get_id(e));
if (list == NULL) {
curl_slist_free_all(beg);
return NULL;
}
else if (beg == NULL) {
beg = list;
}
}
#endif #endif
(void) data; (void) data;
return (list); return (list);