summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2012-03-15 09:34:20 +0000
committerDaniel Stone <daniel@fooishbar.org>2012-03-15 09:44:55 +0000
commit9452165837ebc2ad5c1a02b7d32a95961206350a (patch)
tree5bb2fee1544b5ce495630a86c6daeb85f28413b6 /src
parent937d40492cefb3922a91c440302b0f9085290405 (diff)
downloadxorg-lib-libxkbcommon-9452165837ebc2ad5c1a02b7d32a95961206350a.tar.gz
Plug leaks in geometry parsing
When parsing a geometry file, don't leak the elements we've created. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'src')
-rw-r--r--src/xkbcomp/parseutils.c5
-rw-r--r--src/xkbcomp/parseutils.h3
-rw-r--r--src/xkbcomp/xkbparse.y32
3 files changed, 25 insertions, 15 deletions
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index a36d015..107be23 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -614,9 +614,6 @@ StmtSetMerge(ParseCommon * stmt, unsigned merge)
}
static void
-FreeStmt(ParseCommon *stmt);
-
-static void
FreeExpr(ExprDef *expr)
{
int i;
@@ -677,7 +674,7 @@ FreeInclude(IncludeStmt *incl)
}
}
-static void
+void
FreeStmt(ParseCommon *stmt)
{
ParseCommon *next;
diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h
index 18c2c6c..89458df 100644
--- a/src/xkbcomp/parseutils.h
+++ b/src/xkbcomp/parseutils.h
@@ -154,4 +154,7 @@ extern void setScanState(const char * /* file */ ,
int /* line */
);
+extern void FreeStmt(ParseCommon * /* stmt */
+ );
+
#endif /* XKBPARSE_H */
diff --git a/src/xkbcomp/xkbparse.y b/src/xkbcomp/xkbparse.y
index 7c18e32..13e5628 100644
--- a/src/xkbcomp/xkbparse.y
+++ b/src/xkbcomp/xkbparse.y
@@ -194,18 +194,30 @@ XkbMapConfig : OptFlags FileType OptMapName OBRACE
CBRACE SEMI
{
if ($2 == XkmGeometryIndex)
+ {
+ free($3);
+ FreeStmt($5);
$$= NULL;
+ }
else
+ {
$$= CreateXKBFile($2,$3,$5,$1);
+ }
}
;
XkbConfig : OptFlags FileType OptMapName DeclList
{
if ($2 == XkmGeometryIndex)
+ {
+ free($3);
+ FreeStmt($4);
$$= NULL;
+ }
else
+ {
$$= CreateXKBFile($2,$3,$4,$1);
+ }
}
;
@@ -455,11 +467,11 @@ SectionBody : SectionBody SectionBodyItem
SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI
{ $$= NULL; }
| VarDecl
- { $$= NULL; }
+ { FreeStmt(&$1->common); $$= NULL; }
| DoodadDecl
{ $$= NULL; }
| IndicatorMapDecl
- { $$= NULL; }
+ { FreeStmt(&$1->common); $$= NULL; }
| OverlayDecl
{ $$= NULL; }
;
@@ -473,7 +485,7 @@ RowBody : RowBody RowBodyItem
RowBodyItem : KEYS OBRACE Keys CBRACE SEMI
{ $$= NULL; }
| VarDecl
- { $$= NULL; }
+ { FreeStmt(&$1->common); $$= NULL; }
;
Keys : Keys COMMA Key
@@ -483,9 +495,9 @@ Keys : Keys COMMA Key
;
Key : KeyName
- { $$= NULL; }
+ { free($1); $$= NULL; }
| OBRACE ExprList CBRACE
- { $$= NULL; }
+ { FreeStmt(&$2->common); $$= NULL; }
;
OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
@@ -493,15 +505,13 @@ OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
;
OverlayKeyList : OverlayKeyList COMMA OverlayKey
- {
- $$= NULL;
- }
+ { $$= NULL; }
| OverlayKey
{ $$= NULL; }
;
OverlayKey : KeyName EQUALS KeyName
- { $$= NULL; }
+ { free($1); free($3); $$= NULL; }
;
OutlineList : OutlineList COMMA OutlineInList
@@ -515,7 +525,7 @@ OutlineInList : OBRACE CoordList CBRACE
| Ident EQUALS OBRACE CoordList CBRACE
{ $$= NULL; }
| Ident EQUALS Expr
- { $$= NULL; }
+ { FreeStmt(&$3->common); $$= NULL; }
;
CoordList : CoordList COMMA Coord
@@ -529,7 +539,7 @@ Coord : OBRACKET SignedNumber COMMA SignedNumber CBRACKET
;
DoodadDecl : DoodadType String OBRACE VarDeclList CBRACE SEMI
- { $$= NULL; }
+ { FreeStmt(&$4->common); $$= NULL; }
;
DoodadType : TEXT { $$= 0; }