diff options
author | Yang Tse <yangsita@gmail.com> | 2011-10-07 20:50:57 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2011-10-07 20:50:57 +0200 |
commit | 17f48fe87979f159e2d8769d678641c60f4c0eed (patch) | |
tree | 322c1d34d9c8d0a4d203d127765818f297ac93c7 /lib/cookie.c | |
parent | b82bd05354cfa756a013d2bed4ffdc951ce903db (diff) | |
download | curl-17f48fe87979f159e2d8769d678641c60f4c0eed.tar.gz |
libcurl: some OOM handling fixes
Diffstat (limited to 'lib/cookie.c')
-rw-r--r-- | lib/cookie.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/cookie.c b/lib/cookie.c index 52a2ccb05..fc684ca1b 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -1107,23 +1107,20 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data) c = data->cookies->cookies; - beg = list; while(c) { /* fill the list with _all_ the cookies we know */ line = get_netscape_format(c); - if(line == NULL) { - curl_slist_free_all(beg); + if(!line) { + curl_slist_free_all(list); return NULL; } - list = curl_slist_append(list, line); + beg = curl_slist_append(list, line); free(line); - if(list == NULL) { - curl_slist_free_all(beg); + if(!beg) { + curl_slist_free_all(list); return NULL; } - else if(beg == NULL) { - beg = list; - } + list = beg; c = c->next; } @@ -1148,10 +1145,12 @@ void Curl_flush_cookies(struct SessionHandle *data, int cleanup) data->set.str[STRING_COOKIEJAR]); } else { - if(cleanup && data->change.cookielist) + if(cleanup && data->change.cookielist) { /* since nothing is written, we can just free the list of cookie file names */ curl_slist_free_all(data->change.cookielist); /* clean up list */ + data->change.cookielist = NULL; + } Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); } |