From 00706daa499fd3b48d75de3b2b99b90e9b2b862d Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 22 Mar 2001 20:54:52 +0000 Subject: [PATCH] Fix a compiler crash that happens after a function definition with two or more identical parameter names. The input is of course wrong, but the compiler shouldn't crash. git-svn-id: svn://svn.cc65.org/cc65/trunk@644 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/expr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 5d59e0b96..dc05dcfee 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -561,10 +561,18 @@ static void callfunction (struct expent* lval) /* Fetch the pointer to the next argument, check for too many args */ if (ParamCount <= Func->ParamCount) { + /* Beware: If there are parameters with identical names, they + * cannot go into the same symbol table, which means that in this + * case of errorneous input, the number of nodes in the symbol + * table and ParamCount are NOT equal. We have to handle this case + * below to avoid segmentation violations. Since we know that this + * problem can only occur if there is more than one parameter, + * we will just use the last one. + */ if (ParamCount == 1) { - /* First argument */ - Param = Func->SymTab->SymHead; - } else { + /* First argument */ + Param = Func->SymTab->SymHead; + } else if (Param->NextSym != 0) { /* Next argument */ Param = Param->NextSym; CHECK ((Param->Flags & SC_PARAM) != 0); -- 2.39.5