Skip to content

Commit efdb05d

Browse files
chirowismill
authored andcommitted
parser: Do now allow the empty symbol declaration
An empty element is allowed in SymbolsBody definition, so the following keymap is gramatically correct. ``` xkb_keymap { ... xkb_symbols "sym" { key <SPC> {, [Space] }; }; }; ``` However, the current parser crashes with the keymap due to null pointer access. This change fixes it by changing the parser not to allow it.
1 parent 43c9752 commit efdb05d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/xkbcomp/parser.y

-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ SymbolsBody : SymbolsBody COMMA SymbolsVarDecl
465465
{ $$.head = $1.head; $$.last->common.next = &$3->common; $$.last = $3; }
466466
| SymbolsVarDecl
467467
{ $$.head = $$.last = $1; }
468-
| { $$.head = $$.last = NULL; }
469468
;
470469

471470
SymbolsVarDecl : Lhs EQUALS Expr { $$ = VarCreate($1, $3); }
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
xkb_keymap {
2+
xkb_keycodes { include "evdev+aliases(qwerty)" };
3+
xkb_types { include "complete" };
4+
xkb_compat { include "complete" };
5+
xkb_symbols "sym" {
6+
// This syntax caused the crash in parser before, and is not accepted
7+
// anymore.
8+
key <SPC> { , [Space] };
9+
};
10+
};

test/filecomp.c

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ main(void)
5454
assert(!test_file(ctx, "keymaps/bad.xkb"));
5555
assert(!test_file(ctx, "keymaps/syntax-error.xkb"));
5656
assert(!test_file(ctx, "keymaps/syntax-error2.xkb"));
57+
assert(!test_file(ctx, "keymaps/empty-symbol-decl.xkb"));
5758
assert(!test_file(ctx, "does not exist"));
5859

5960
/* Test response to invalid flags and formats. */

0 commit comments

Comments
 (0)