mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
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!
This commit is contained in:
@@ -398,6 +398,8 @@ static void readSection(FILE *file, struct Section *section, char const *fileNam
|
|||||||
for (uint32_t i = 0; i < section->nbPatches; i++)
|
for (uint32_t i = 0; i < section->nbPatches; i++)
|
||||||
readPatch(file, &patches[i], fileName, section->name, i, fileNodes);
|
readPatch(file, &patches[i], fileName, section->name, i, fileNodes);
|
||||||
section->patches = patches;
|
section->patches = patches;
|
||||||
|
} else {
|
||||||
|
section->data = NULL; // `mergeSections()` expects to be able to always read the ptr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user