Commit 30d88b93e7d5f3db760978c4740ed3f37dcf215d

Ran Benita 2012-03-01T20:44:42

Don't leak the scanner's buffer Signed-off-by: Ran Benita <ran234@gmail.com>

diff --git a/src/xkbcomp/xkbscan.l b/src/xkbcomp/xkbscan.l
index 4b02b65..478dd04 100644
--- a/src/xkbcomp/xkbscan.l
+++ b/src/xkbcomp/xkbscan.l
@@ -229,20 +229,18 @@ XKBParseString(const char *string, XkbFile ** pRtrn)
 int
 XKBParseFile(FILE * file, XkbFile ** pRtrn)
 {
-    if (file)
-    {
-        yyin = file;
-        rtrnValue = NULL;
-        if (yyparse() == 0)
-        {
-            *pRtrn = rtrnValue;
-            CheckDefaultMap(rtrnValue);
-            rtrnValue = NULL;
-            return 1;
-        }
-        *pRtrn = NULL;
-        return 0;
-    }
     *pRtrn = NULL;
+    if (!file)
+        return 1;
+
+    yyin = file;
+    rtrnValue = NULL;
+    if (yyparse() != 0)
+        return 0;
+
+    yylex_destroy();
+    *pRtrn = rtrnValue;
+    CheckDefaultMap(rtrnValue);
+    rtrnValue = NULL;
     return 1;
 }