uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit a373939544b3877ed2678b92a4b7264e003c6dd0
parent a3ee7ab98278a9e8ae5dfe10bed519a1dfa7a7ea
Author: Claude Heiland-Allen <claude@mathr.co.uk>
Date:   Tue, 26 Oct 2021 16:59:04 +0100

uxnasm errors-out if too many labels

Diffstat:
Msrc/uxnasm.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/uxnasm.c b/src/uxnasm.c @@ -14,6 +14,8 @@ WITH REGARD TO THIS SOFTWARE. #define TRIM 0x0100 #define LENGTH 0x10000 +#define LABELS 512 + typedef unsigned char Uint8; typedef signed char Sint8; typedef unsigned short Uint16; @@ -31,7 +33,7 @@ typedef struct { typedef struct { Uint8 data[LENGTH], mlen; Uint16 ptr, length, llen; - Label labels[512]; + Label labels[LABELS]; Macro macros[256]; } Program; @@ -178,6 +180,8 @@ makelabel(char *name) return error("Label name is hex number", name); if(findopcode(name) || scmp(name, "BRK", 4) || !slen(name)) return error("Label name is invalid", name); + if(p.llen == LABELS) + return error("Too many labels", name); l = &p.labels[p.llen++]; l->addr = addr; l->refs = 0;