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

CURLINFO_COOKIELIST.3: made the example not leak memory

Reported-by: Muz Dima
This commit is contained in:
Daniel Stenberg 2018-03-20 23:18:23 +01:00
parent c1366571b6
commit 27d7e511d5
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms
@ -56,9 +56,10 @@ if(curl) {
res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies); res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if(!res && cookies) { if(!res && cookies) {
/* a linked list of cookies in cookie file format */ /* a linked list of cookies in cookie file format */
while(cookies) { struct curl_slist *each = cookies;
printf("%s", cookies->data); while(each) {
cookies = cookies->next; printf("%s", each->data);
each = each->next;
} }
/* we must free these cookies when we're done */ /* we must free these cookies when we're done */
curl_slist_free_all(cookies); curl_slist_free_all(cookies);