summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2016-03-22 11:11:14 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-03-22 11:16:24 (GMT)
commit03b7314673fc4030e933f86890aad7f82ec30eca (patch) (side-by-side diff)
tree0e9e00ce9cfc5a52a2ff21c06f800b7b9879a22a /src
parentf91b19e696794204f2ba05587eb0dc0475c65345 (diff)
downloadcflow-03b7314673fc4030e933f86890aad7f82ec30eca.tar.gz
cflow-03b7314673fc4030e933f86890aad7f82ec30eca.tar.bz2
Properly handle invalid input
See https://savannah.gnu.org/bugs/?44113 * src/parser.c (cleanup_stack): Ignore negative deltas. (parse_function_declaration): Don't set caller if the symbol is in automatic storage. Note: that means nested function definitions can't be handled. * tests/invalid.at: New test case. * tests/Makefile.am: Add new test case. * tests/testsuite.at: Likewise.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/parser.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c
index 4126145..4be9d4e 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -274,9 +274,10 @@ cleanup_stack()
{
int delta = tos - curs;
- if (delta)
+ if (delta > 0)
memmove(token_stack, token_stack+curs, delta*sizeof(token_stack[0]));
-
+ else if (delta < 0) /* Invalid input */
+ delta = 0;
tos = delta;
curs = 0;
}
@@ -652,6 +653,8 @@ parse_function_declaration(Ident *ident, int parm)
case LBRACE:
if (ident->name) {
caller = lookup(ident->name);
+ if (caller && caller->storage == AutoStorage)
+ caller = NULL;
func_body();
}
break;

Return to:

Send suggestions and report system problems to the System administrator.