aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-03-22 13:11:14 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-03-22 13:16:24 +0200
commit03b7314673fc4030e933f86890aad7f82ec30eca (patch)
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')
-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
@@ -276,5 +276,6 @@ cleanup_stack()
- 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;
@@ -654,2 +655,4 @@ parse_function_declaration(Ident *ident, int parm)
caller = lookup(ident->name);
+ if (caller && caller->storage == AutoStorage)
+ caller = NULL;
func_body();

Return to:

Send suggestions and report system problems to the System administrator.