Fix crash on error 33 in ternary operator
If one of the two values is a string literal and the other is a non-array, the symbol associated with the first one will be NULL. But the code checked if sym->name!=NULL rather than sym!=NULL, hence the crash. --------- test code -------- main() { new a, b; return (a != 0 ? b : "string"); } ----- end of test code -----
This commit is contained in:
parent
7f30a03f94
commit
4d2c600507
@ -1111,10 +1111,10 @@ static int hier13(value *lval)
|
||||
array1= (lval->ident==iARRAY || lval->ident==iREFARRAY);
|
||||
array2= (lval2.ident==iARRAY || lval2.ident==iREFARRAY);
|
||||
if (array1 && !array2) {
|
||||
char *ptr=(lval->sym->name!=NULL) ? lval->sym->name : "-unknown-";
|
||||
char *ptr=(lval->sym!=NULL) ? lval->sym->name : "-unknown-";
|
||||
error(33,ptr); /* array must be indexed */
|
||||
} else if (!array1 && array2) {
|
||||
char *ptr=(lval2.sym->name!=NULL) ? lval2.sym->name : "-unknown-";
|
||||
char *ptr=(lval2.sym!=NULL) ? lval2.sym->name : "-unknown-";
|
||||
error(33,ptr); /* array must be indexed */
|
||||
} /* if */
|
||||
/* ??? if both are arrays, should check dimensions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user