wscanf: fix memory leak

(cherry picked from commit b46245ee0cbbe9e1329498609e68930753a1ec12)
diff --git a/mingw-w64-crt/stdio/mingw_wvfscanf.c b/mingw-w64-crt/stdio/mingw_wvfscanf.c
index 41bdc68..045aba7 100644
--- a/mingw-w64-crt/stdio/mingw_wvfscanf.c
+++ b/mingw-w64-crt/stdio/mingw_wvfscanf.c
@@ -213,6 +213,11 @@
   struct gcollect *pf;
   size_t cnt;
 
+  if (wbuf)
+    {
+      free (*wbuf);
+      *wbuf = NULL;
+    }
   if (!pt || (pf = *pt) == NULL)
     return;
   while (pf != NULL)
@@ -227,11 +232,6 @@
       free (pf_sv);
     }
   *pt = NULL;
-  if (wbuf)
-    {
-      free (*wbuf);
-      *wbuf = NULL;
-    }
 }
 
 static int