From 2e137d4387f2b01eea0b6f19744a19abb182c1b1 Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Sun, 6 Oct 2019 23:40:10 +0200 Subject: [PATCH] Fix crash when referencing undeclared arrays When declaring a variable or constant referencing an address of an element of an undeclared array, the compiler crashed. Fixed. --- tests/functional/dim_test0.bas | 6 ++++++ zxbparser.py | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 tests/functional/dim_test0.bas diff --git a/tests/functional/dim_test0.bas b/tests/functional/dim_test0.bas new file mode 100644 index 000000000..ae6b98f24 --- /dev/null +++ b/tests/functional/dim_test0.bas @@ -0,0 +1,6 @@ + +DIM a AT @c(1, 5) +DIM c(10, 10) as UBYTE + +const q = @c(2, 3) + diff --git a/zxbparser.py b/zxbparser.py index a3fdb6814..77a24ef20 100755 --- a/zxbparser.py +++ b/zxbparser.py @@ -622,6 +622,9 @@ def p_var_decl_at(p): """ p[0] = None + if p[2] is None or p[3] is None or p[5] is None: + return + if len(p[2]) != 1: syntax_error(p.lineno(1), 'Only one variable at a time can be declared this way')