diff options
author | Ran Benita <ran234@gmail.com> | 2014-07-27 14:24:20 +0300 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2014-07-27 14:32:18 +0300 |
commit | 40f109af56493605410f2bea891779fbbfa3fda9 (patch) | |
tree | 7f0f9cb87f1c25024556231325e0dcf501195054 | |
parent | 37cf20c90635c8cce675393ce885376795b553ea (diff) | |
download | libxkbcommon-40f109af56493605410f2bea891779fbbfa3fda9.tar.gz libxkbcommon-40f109af56493605410f2bea891779fbbfa3fda9.tar.bz2 libxkbcommon-40f109af56493605410f2bea891779fbbfa3fda9.zip |
ast-build: make sure InterpDef is freeable
With the following two rules:
InterpretDecl : INTERPRET InterpretMatch OBRACE
VarDeclList
CBRACE SEMI
{ $2->def = $4; $$ = $2; }
;
InterpretMatch : KeySym PLUS Expr
{ $$ = InterpCreate($1, $3); }
| KeySym
{ $$ = InterpCreate($1, NULL); }
;
And the fact that InterpCreate doesn't initialize ->def, if the
VarDeclList fails, the %destructor tries to recursively free the
uninitialized ->def VarDef. So always initialize it.
That was the only problematic code in the parser for %destructor (I'm
pretty sure).
Signed-off-by: Ran Benita <ran234@gmail.com>
-rw-r--r-- | src/xkbcomp/ast-build.c | 1 | ||||
-rw-r--r-- | test/data/keymaps/syntax-error2.xkb | 7 | ||||
-rw-r--r-- | test/filecomp.c | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c index 4ce1cc4..58c482c 100644 --- a/src/xkbcomp/ast-build.c +++ b/src/xkbcomp/ast-build.c @@ -325,6 +325,7 @@ InterpCreate(xkb_keysym_t sym, ExprDef *match) def->common.next = NULL; def->sym = sym; def->match = match; + def->def = NULL; return def; } diff --git a/test/data/keymaps/syntax-error2.xkb b/test/data/keymaps/syntax-error2.xkb new file mode 100644 index 0000000..0ca28f2 --- /dev/null +++ b/test/data/keymaps/syntax-error2.xkb @@ -0,0 +1,7 @@ +xkb_keymap { +xkb_compatibility "complete" { + interpret ISO_Level2_Latch+Exactly(Shift) { + action == LatchMods(modifiers=Shift,clearLocks,latchToLock); + }; +}; +}; diff --git a/test/filecomp.c b/test/filecomp.c index 5f083ee..ced2472 100644 --- a/test/filecomp.c +++ b/test/filecomp.c @@ -48,6 +48,7 @@ main(void) assert(!test_file(ctx, "keymaps/divide-by-zero.xkb")); assert(!test_file(ctx, "keymaps/bad.xkb")); assert(!test_file(ctx, "keymaps/syntax-error.xkb")); + assert(!test_file(ctx, "keymaps/syntax-error2.xkb")); assert(!test_file(ctx, "does not exist")); /* Test response to invalid flags and formats. */ |