From af31143ec3afe9ef2c0037ea785d8028025637d1 Mon Sep 17 00:00:00 2001 From: Daniel_Cortez Date: Mon, 30 Oct 2017 18:59:21 +0700 Subject: [PATCH] emit/__emit: Avoid excess instruction name copying in emit_findopcode() --- source/compiler/sc1.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index a88bc99..3e19e67 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -6290,14 +6290,10 @@ static EMIT_OPCODE emit_opcodelist[] = { { 92, "zero.s", emit_parm1_num }, }; -static int emit_findopcode(char *instr,int maxlen) +static int emit_findopcode(const char *instr,int maxlen) { int low,high,mid,cmp; - char str[MAX_INSTR_LEN]; - if (maxlen>=MAX_INSTR_LEN) - return 0; - strlcpy(str,instr,maxlen+1); /* look up the instruction with a binary search * the assembler is case insensitive to instructions (but case sensitive * to symbols) @@ -6307,7 +6303,7 @@ static int emit_findopcode(char *instr,int maxlen) while (low0) low=mid+1; else @@ -6315,7 +6311,7 @@ static int emit_findopcode(char *instr,int maxlen) } /* while */ assert(low==high); - if (stricmp(str,emit_opcodelist[low].name)==0) + if (stricmp(instr,emit_opcodelist[low].name)==0) return low; /* found */ return 0; /* not found, return special index */ }