From: cuz Date: Thu, 7 Aug 2003 11:12:39 +0000 (+0000) Subject: Fixed a bug X-Git-Tag: V2.12.0~1473 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b1f89ab7937f7d97e97e60f6ab985868c9c67c59;p=cc65 Fixed a bug git-svn-id: svn://svn.cc65.org/cc65/trunk@2250 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ca65/instr.c b/src/ca65/instr.c index dd1729ec3..7d80bd74c 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -887,7 +887,14 @@ int FindInstruction (const char* Ident) /* Make a copy, and uppercase that copy */ I = 0; - while (Ident[I]) { + while (Ident[I] != '\0') { + /* If the identifier is longer than the longest mnemonic, it cannot + * be one. + */ + if (I >= sizeof (Key) - 1) { + /* Not found, no need for further action */ + return -1; + } Key[I] = toupper ((unsigned char)Ident[I]); ++I; } diff --git a/src/ca65/instr.h b/src/ca65/instr.h index 20f957203..7429e447c 100644 --- a/src/ca65/instr.h +++ b/src/ca65/instr.h @@ -97,7 +97,7 @@ /* Description for one instruction */ typedef struct InsDesc InsDesc; struct InsDesc { - char Mnemonic [8]; + char Mnemonic[5]; unsigned long AddrMode; /* Valid adressing modes */ unsigned char BaseCode; /* Base opcode */ unsigned char ExtCode; /* Number of ext code table */