Skip to content

Commit

Permalink
__emit: Fix crash on attempt to reference a native
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Cortez committed Apr 27, 2019
1 parent 69a573a commit 3c1ac1e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions source/compiler/sc1.c
Expand Up @@ -6088,14 +6088,15 @@ static int SC_FASTCALL emit_param_any_internal(emit_outval *p,int expected_tok,
p->type=eotLABEL;
p->value.ucell=(ucell)sym->addr;
} else if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
const int ntvref=sym->usage & uREAD;
markusage(sym,uREAD);
if (negate)
goto invalid_token_neg;
if (!allow_nonint) {
tok=(sym->usage & uNATIVE) ? teNATIVE : teFUNCTN;
goto invalid_token;
} /* if */
if ((sym->usage & uNATIVE)!=0 && (sym->usage & uREAD)==0 && sym->addr>=0)
if ((sym->usage & uNATIVE)!=0 && ntvref==0 && sym->addr>=0)
sym->addr=ntv_funcid++;
p->type=eotFUNCTION;
p->value.string=str;
Expand Down Expand Up @@ -6361,7 +6362,7 @@ static void SC_FASTCALL emit_param_function(emit_outval *p,int isnative)
cell val;
char *str;
symbol *sym;
int tok;
int tok,ntvref;

p->type=eotNUMBER;
tok=lex(&val,&str);
Expand All @@ -6376,6 +6377,7 @@ static void SC_FASTCALL emit_param_function(emit_outval *p,int isnative)
return;
} /* if */
if (sym->ident==iFUNCTN || sym->ident==iREFFUNC) {
ntvref=sym->usage & uREAD;
markusage(sym,uREAD);
if (!!(sym->usage & uNATIVE)==isnative)
break;
Expand All @@ -6396,7 +6398,7 @@ static void SC_FASTCALL emit_param_function(emit_outval *p,int isnative)
} /* switch */

if (isnative!=FALSE) {
if ((sym->usage & uREAD)==0 && sym->addr>=0)
if (ntvref==0 && sym->addr>=0)
sym->addr=ntv_funcid++;
p->value.ucell=(ucell)sym->addr;
} else {
Expand Down

0 comments on commit 3c1ac1e

Please sign in to comment.