From 5bc8ff98de9e7d942b7920645ce1a162d93af3ab Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Sun, 19 Feb 2023 09:01:17 -0500 Subject: [PATCH] error if computed memory size is negative --- src/ld65/config.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ld65/config.c b/src/ld65/config.c index c22ced1ef..6606df7e3 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -1936,6 +1936,11 @@ unsigned CfgProcess (void) GetString (M->Name)); } M->Size = GetExprVal (M->SizeExpr); + if (M->Size >= 0x80000000) { + CfgError (GetSourcePos (M->LI), + "Size of memory area '%s' is negative: %ld", + GetString (M->Name), (long)M->Size); + } /* Walk through the segments in this memory area */ for (J = 0; J < CollCount (&M->SegList); ++J) {