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 */