From 4db7198ade28586f67152be8850b013bf52c98c3 Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 11 Aug 2002 14:49:42 +0000 Subject: [PATCH] AllocIf would overwrite memory if the .IF nesting became too deep. git-svn-id: svn://svn.cc65.org/cc65/trunk@1389 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/condasm.c | 4 ++-- src/ca65/error.c | 4 ++-- src/ca65/error.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ca65/condasm.c b/src/ca65/condasm.c index 68c1b181b..1f6f96cb3 100644 --- a/src/ca65/condasm.c +++ b/src/ca65/condasm.c @@ -70,7 +70,7 @@ enum { /* One .IF descriptor */ typedef struct IfDesc IfDesc; -struct IfDesc { +struct IfDesc { unsigned Flags; /* Bitmapped flags, see above */ FilePos Pos; /* File position of the .IF */ const char* Name; /* Name of the directive */ @@ -89,7 +89,7 @@ static IfDesc* AllocIf (const char* Directive, int NeedTerm) /* Check for stack overflow */ if (IfCount >= MAX_IFS) { - Error (ERR_IF_NESTING); + Fatal (FAT_IF_NESTING); } /* Alloc one element */ diff --git a/src/ca65/error.c b/src/ca65/error.c index 849e5eb5f..ba4de8269 100644 --- a/src/ca65/error.c +++ b/src/ca65/error.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-2002 Ullrich von Bassewitz */ /* Wacholderweg 14 */ /* D-70597 Stuttgart */ /* EMail: uz@musoftware.de */ @@ -168,7 +168,6 @@ void ErrorMsg (const FilePos* Pos, unsigned ErrNum, va_list ap) "Symbol `%s' is already marked as export", "Exported symbol `%s' is undefined", "Exported values must be constant", - ".IF nesting too deep", "Unexpected end of file", "Unexpected end of line", "Unexpected `%s'", @@ -257,6 +256,7 @@ void Fatal (unsigned FatNum, ...) "Cannot write to listing file: %s", "Cannot read from listing file: %s", "Too many nested constructs", + ".IF nesting too deep", "Too many symbols", }; va_list ap; diff --git a/src/ca65/error.h b/src/ca65/error.h index 54e2ae198..311b47c2a 100644 --- a/src/ca65/error.h +++ b/src/ca65/error.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2000 Ullrich von Bassewitz */ +/* (C) 1998-2002 Ullrich von Bassewitz */ /* Wacholderweg 14 */ /* D-70597 Stuttgart */ /* EMail: uz@musoftware.de */ @@ -109,7 +109,6 @@ enum Errors { ERR_SYM_ALREADY_EXPORT, ERR_EXPORT_UNDEFINED, ERR_EXPORT_MUST_BE_CONST, - ERR_IF_NESTING, ERR_UNEXPECTED_EOF, ERR_UNEXPECTED_EOL, ERR_UNEXPECTED, @@ -148,6 +147,7 @@ enum Fatals { FAT_CANNOT_WRITE_LISTING, FAT_CANNOT_READ_LISTING, FAT_NESTING, + FAT_IF_NESTING, FAT_TOO_MANY_SYMBOLS, FAT_COUNT /* Fatal error count */ }; -- 2.39.5