mirror of
https://github.com/janet-lang/janet
synced 2024-12-21 05:50:27 +00:00
Fix peg bug when there is no default grammar set.
This could result in a segfault when we attempt to read from a NULL pointer.
This commit is contained in:
parent
81186bf262
commit
2db7945d6f
@ -1148,7 +1148,9 @@ static uint32_t peg_compile1(Builder *b, Janet peg) {
|
||||
for (; i > 0 && janet_checktype(peg, JANET_KEYWORD); --i) {
|
||||
Janet nextPeg = janet_table_get_ex(grammar, peg, &grammar);
|
||||
if (!grammar || janet_checktype(nextPeg, JANET_NIL)) {
|
||||
nextPeg = janet_table_get(b->default_grammar, peg);
|
||||
nextPeg = (b->default_grammar == NULL)
|
||||
? janet_wrap_nil()
|
||||
: janet_table_get(b->default_grammar, peg);
|
||||
if (janet_checktype(nextPeg, JANET_NIL)) {
|
||||
peg_panic(b, "unknown rule");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user