From 9fd4ba90cc99ad5ce431a68e0ec9e069e2d290a7 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Wed, 14 Aug 2024 01:44:08 +0200 Subject: [PATCH] Trap invalid section types in RGBDS objs --- src/link/object.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/link/object.cpp b/src/link/object.cpp index 936fb897..946a58cc 100644 --- a/src/link/object.cpp +++ b/src/link/object.cpp @@ -354,7 +354,11 @@ static void readSection( tryGetc( uint8_t, byte, file, "%s: Cannot read \"%s\"'s type: %s", fileName, section.name.c_str() ); - section.type = (SectionType)(byte & 0x3F); + if (uint8_t type = byte & 0x3F; type >= SECTTYPE_INVALID) { + errx("\"%s\" has unknown section type 0x%02x", section.name.c_str(), type); + } else { + section.type = SectionType(type); + } if (byte >> 7) section.modifier = SECTION_UNION; else if (byte >> 6)