From d207064aa6b4bb447f2572ed4984ac5857e69ac4 Mon Sep 17 00:00:00 2001
From: Hannes Domani <ssbssa@yahoo.de>
Date: Wed, 24 Feb 2016 19:50:02 +0100
Subject: [PATCH] scanf: fix memory leak

---
 mingw-w64-crt/stdio/mingw_vfscanf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-crt/stdio/mingw_vfscanf.c b/mingw-w64-crt/stdio/mingw_vfscanf.c
index 5c8be6f..6828caa 100644
--- a/mingw-w64-crt/stdio/mingw_vfscanf.c
+++ b/mingw-w64-crt/stdio/mingw_vfscanf.c
@@ -210,6 +210,11 @@ release_ptrs (struct gcollect **pt, char **wbuf)
   struct gcollect *pf;
   size_t cnt;
 
+  if (wbuf)
+    {
+      free (*wbuf);
+      *wbuf = NULL;
+    }
   if (!pt || (pf = *pt) == NULL)
     return;
   while (pf != NULL)
@@ -224,11 +229,6 @@ release_ptrs (struct gcollect **pt, char **wbuf)
       free (pf_sv);
     }
   *pt = NULL;
-  if (wbuf)
-    {
-      free (*wbuf);
-      *wbuf = NULL;
-    }
 }
 
 static int
-- 
1.9.4.msysgit.2

