Don't leak the scanner's buffer Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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;
}