]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
CURLINFO_COOKIELIST.3: made the example not leak memory
authorDaniel Stenberg <daniel@haxx.se>
Tue, 20 Mar 2018 22:18:23 +0000 (23:18 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 20 Mar 2018 22:18:23 +0000 (23:18 +0100)
Reported-by: Muz Dima
docs/libcurl/opts/CURLINFO_COOKIELIST.3

index 18203dba771ed5ff1133d15f08e8eeb3022a0817..a204890648651c1e53e908987a71b4cafa50d2f7 100644 (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
 .\" * 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);
     if(!res && cookies) {
       /* a linked list of cookies in cookie file format */
-      while(cookies) {
-        printf("%s", cookies->data);
-        cookies = cookies->next;
+      struct curl_slist *each = cookies;
+      while(each) {
+        printf("%s", each->data);
+        each = each->next;
       }
       /* we must free these cookies when we're done */
       curl_slist_free_all(cookies);