From b1f89ab7937f7d97e97e60f6ab985868c9c67c59 Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 7 Aug 2003 11:12:39 +0000 Subject: [PATCH] Fixed a bug git-svn-id: svn://svn.cc65.org/cc65/trunk@2250 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/instr.c | 9 ++++++++- src/ca65/instr.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) 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 */ -- 2.39.5