From b5d9e857053c8a1f5c56a27903b5f133048aa1ee Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sun, 22 Apr 2018 23:43:57 +0200 Subject: [PATCH] Fix segfault when recovering from syntax error after the last global Per bug report by @thickbrick. Fixes #79, and another issue with globals not being always declared in case of syntax error. --- lslmini.y | 12 ++++++------ scripts/bugs/0079a.lsl | 3 +++ scripts/bugs/0079b.lsl | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 scripts/bugs/0079a.lsl create mode 100644 scripts/bugs/0079b.lsl diff --git a/lslmini.y b/lslmini.y index 256794a..19faff1 100644 --- a/lslmini.y +++ b/lslmini.y @@ -242,18 +242,14 @@ globals } | global globals { - if ( $1 ) { + if ( $1 && $2 ) { DEBUG( LOG_DEBUG_SPAM, NULL, "** global [%p,%p] globals [%p,%p]\n", $1->get_prev(), $1->get_next(), $2->get_prev(), $2->get_next()); $1->add_next_sibling($2); $$ = $1; } else { - $$ = $2; + $$ = $2 ? $2 : $1; } } - | error ';' - { - $$ = NULL; - } ; global @@ -265,6 +261,10 @@ global { $$ = new LLScriptGlobalStorage(NULL, $1); } + | error ';' + { + $$ = NULL; + } ; name_type diff --git a/scripts/bugs/0079a.lsl b/scripts/bugs/0079a.lsl new file mode 100644 index 0000000..061c90b --- /dev/null +++ b/scripts/bugs/0079a.lsl @@ -0,0 +1,3 @@ +integer a; // $[E20009] Declared but not used +b; // $[E10019] Syntax error (it was causing a segfault) +default { state_entry() {} } diff --git a/scripts/bugs/0079b.lsl b/scripts/bugs/0079b.lsl new file mode 100644 index 0000000..4adebc1 --- /dev/null +++ b/scripts/bugs/0079b.lsl @@ -0,0 +1,4 @@ +integer a; // $[E20009] Declared and not used +b; // $[E10019] Syntax error +integer c; // $[E20009] Declared and not used +default { state_entry() {} }