From 75a07a90f842382d7f888def0eb0104391620099 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Fri, 2 Dec 2022 22:39:31 +0100 Subject: [PATCH] Always initialise `section->data` to avoid an uninit read The addition of SDCC objects required a change in the logic of `mergeSections()` to dispatch based on `->data` instead of `sect_HasData`, which implicitly assumes that `->data` is always initialised (maybe NULL). However, RGBDS sections did not do that! --- src/link/object.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/link/object.c b/src/link/object.c index 89b7fa9f..d55afa1c 100644 --- a/src/link/object.c +++ b/src/link/object.c @@ -398,6 +398,8 @@ static void readSection(FILE *file, struct Section *section, char const *fileNam for (uint32_t i = 0; i < section->nbPatches; i++) readPatch(file, &patches[i], fileName, section->name, i, fileNodes); section->patches = patches; + } else { + section->data = NULL; // `mergeSections()` expects to be able to always read the ptr } }