Fix crash when using tagof(tagname:)

This fixes #18.
This commit is contained in:
Zeex 2014-02-19 22:30:00 +07:00
parent d23e03e7ba
commit 53ef10ffc7

View File

@ -1220,6 +1220,7 @@ static int hier2(value *lval)
symbol *sym; symbol *sym;
int saveresult; int saveresult;
sym=NULL;
tok=lex(&val,&st); tok=lex(&val,&st);
switch (tok) { switch (tok) {
case tINC: /* ++lval */ case tINC: /* ++lval */
@ -1392,7 +1393,7 @@ static int hier2(value *lval)
return error(17,st); /* undefined symbol (symbol is in the table, but it is "used" only) */ return error(17,st); /* undefined symbol (symbol is in the table, but it is "used" only) */
tag=sym->tag; tag=sym->tag;
} /* if */ } /* if */
if (sym->ident==iARRAY || sym->ident==iREFARRAY) { if (sym!=NULL && (sym->ident==iARRAY || sym->ident==iREFARRAY)) {
int level; int level;
symbol *idxsym=NULL; symbol *idxsym=NULL;
symbol *subsym=sym; symbol *subsym=sym;
@ -1414,7 +1415,7 @@ static int hier2(value *lval)
if (level>sym->dim.array.level+1) if (level>sym->dim.array.level+1)
error(28,sym->name); /* invalid subscript */ error(28,sym->name); /* invalid subscript */
else if (level==sym->dim.array.level+1 && idxsym!=NULL) else if (level==sym->dim.array.level+1 && idxsym!=NULL)
tag= idxsym->x.tags.index; tag=idxsym->x.tags.index;
} /* if */ } /* if */
exporttag(tag); exporttag(tag);
clear_value(lval); clear_value(lval);