mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-23 06:07:06 +00:00
Disallow NUL characters in section names and assertion messages
Allowing these in object files would lose anything after the '\0' when RGBLINK reads the object.
This commit is contained in:
@@ -162,6 +162,10 @@ void out_CreatePatch(uint32_t type, Expression const &expr, uint32_t ofs, uint32
|
||||
void out_CreateAssert(
|
||||
AssertionType type, Expression const &expr, std::string const &message, uint32_t ofs
|
||||
) {
|
||||
if (message.find('\0') != std::string::npos) {
|
||||
fatal("Assertion messages cannot contain '\\0' characters");
|
||||
}
|
||||
|
||||
Assertion &assertion = assertions.emplace_front();
|
||||
|
||||
initPatch(assertion.patch, type, expr, ofs);
|
||||
|
||||
@@ -544,6 +544,10 @@ void sect_NewSection(
|
||||
SectionSpec const &attrs,
|
||||
SectionModifier mod
|
||||
) {
|
||||
if (name.find('\0') != std::string::npos) {
|
||||
fatal("Section names cannot contain '\\0' characters");
|
||||
}
|
||||
|
||||
for (SectionStackEntry &entry : sectionStack) {
|
||||
if (entry.section && entry.section->name == name) {
|
||||
fatal("Section \"%s\" is already on the stack", name.c_str());
|
||||
|
||||
Reference in New Issue
Block a user