From 21d3a7f93eb98f75547aaeb192a96c31793cce0e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 12 Jul 2014 09:31:51 -0700 Subject: [PATCH] Fix crash with malformed arguments (bug 6176). --- sourcepawn/compiler/sc1.c | 4 ++++ sourcepawn/compiler/tests/fail-missing-arg-comma.sp | 4 ++++ sourcepawn/compiler/tests/fail-missing-arg-comma.txt | 1 + 3 files changed, 9 insertions(+) create mode 100644 sourcepawn/compiler/tests/fail-missing-arg-comma.sp create mode 100644 sourcepawn/compiler/tests/fail-missing-arg-comma.txt diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 5ff514de..472c28fc 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -6652,6 +6652,10 @@ static void statement(int *lastindent,int allow_decl) } if (is_decl) { + if (!allow_decl) { + error(3); + return; + } lexpush(); autozero = TRUE; lastst = tNEW; diff --git a/sourcepawn/compiler/tests/fail-missing-arg-comma.sp b/sourcepawn/compiler/tests/fail-missing-arg-comma.sp new file mode 100644 index 00000000..9e56d2a3 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-missing-arg-comma.sp @@ -0,0 +1,4 @@ +stock void Function( float array1[ 3 ] float array2[ 3 ] ) +{ + +} diff --git a/sourcepawn/compiler/tests/fail-missing-arg-comma.txt b/sourcepawn/compiler/tests/fail-missing-arg-comma.txt new file mode 100644 index 00000000..418e8963 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-missing-arg-comma.txt @@ -0,0 +1 @@ +(1) : error 001: expected token: ")", but found "-identifier-"