From 30d88b93e7d5f3db760978c4740ed3f37dcf215d Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Thu, 1 Mar 2012 20:44:42 +0200 Subject: [PATCH] Don't leak the scanner's buffer Signed-off-by: Ran Benita --- src/xkbcomp/xkbscan.l | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) 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; } -- 2.7.4