From 3c1ac1e91166aae6f14871d1202712a0a6f245bb Mon Sep 17 00:00:00 2001 From: Daniel_Cortez Date: Mon, 26 Nov 2018 14:47:03 +0700 Subject: [PATCH] __emit: Fix crash on attempt to reference a native --- source/compiler/sc1.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index c7fe923..5c78a8d 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -6088,6 +6088,7 @@ fetchtok: 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; @@ -6095,7 +6096,7 @@ fetchtok: 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; @@ -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); @@ -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; @@ -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 {