From 315693699f5786dd8bfecfa25201fa68da1458cc Mon Sep 17 00:00:00 2001
From: kangenbo <kangenbo@huawei.com>
Date: Fri, 8 Mar 2019 10:55:48 -0500
Subject: [PATCH] cookies: fix leak when writing cookies to file

---
 lib/cookie.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/cookie.c b/lib/cookie.c
index fd7341f..9cf8a36 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -1508,10 +1508,10 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
     format_ptr = get_netscape_format(array[i]);
     if(format_ptr == NULL) {
       fprintf(out, "#\n# Fatal libcurl error\n");
-      if(!use_stdout) {
-        free(array);
+      free(array);
+      if(!use_stdout)
         fclose(out);
-      }
+
       return 1;
     }
     fprintf(out, "%s\n", format_ptr);
-- 
1.8.3.1

