aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cookie.c11
-rw-r--r--lib/ssluse.c11
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index e64bc49e9..d25eb69c3 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -1005,13 +1005,18 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data)
/* fill the list with _all_ the cookies we know */
line = get_netscape_format(c);
if (line == NULL) {
- /* get_netscape_format returns null only if we run out of memory */
-
- curl_slist_free_all(beg); /* free some memory */
+ curl_slist_free_all(beg);
return NULL;
}
list = curl_slist_append(list, line);
free(line);
+ if (list == NULL) {
+ curl_slist_free_all(beg);
+ return NULL;
+ }
+ else if (beg == NULL) {
+ beg = list;
+ }
c = c->next;
}
diff --git a/lib/ssluse.c b/lib/ssluse.c
index d96ee13bf..5c2999dfa 100644
--- a/lib/ssluse.c
+++ b/lib/ssluse.c
@@ -678,10 +678,19 @@ struct curl_slist *Curl_ossl_engines_list(struct SessionHandle *data)
{
struct curl_slist *list = NULL;
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
+ struct curl_slist *beg = NULL;
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));
+ if (list == NULL) {
+ curl_slist_free_all(beg);
+ return NULL;
+ }
+ else if (beg == NULL) {
+ beg = list;
+ }
+ }
#endif
(void) data;
return (list);