mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-19 04:07:05 +00:00
Make array buffers for snprintf just large enough for their uint32_t and uint16_t types
Note that `bank` can store 9 bytes (8 digits plus NUL terminator) even though `section.bank` should never go above 16-bit (4 digits).
This commit is contained in:
+5
-5
@@ -219,14 +219,14 @@ static std::optional<size_t> getPlacement(Section const §ion, MemoryLocation
|
||||
static std::string getSectionDescription(Section const §ion) {
|
||||
std::string description = "\"" + section.name + "\" (" + section.typeInfo().name + " section) ";
|
||||
if (section.isBankFixed && section.typeInfo().isBanked()) {
|
||||
char bank[8];
|
||||
char bank[9];
|
||||
snprintf(bank, sizeof(bank), "%02" PRIx32, section.bank);
|
||||
if (section.isAddressFixed) {
|
||||
char addr[8];
|
||||
char addr[5];
|
||||
snprintf(addr, sizeof(addr), "%04" PRIx16, section.org);
|
||||
description = description + "at $" + bank + ":" + addr;
|
||||
} else if (section.isAlignFixed) {
|
||||
char mask[8];
|
||||
char mask[5];
|
||||
snprintf(mask, sizeof(mask), "%" PRIx16, static_cast<uint16_t>(~section.alignMask));
|
||||
description = description + "in bank $" + bank + " with align mask $" + mask;
|
||||
} else {
|
||||
@@ -234,11 +234,11 @@ static std::string getSectionDescription(Section const §ion) {
|
||||
}
|
||||
} else {
|
||||
if (section.isAddressFixed) {
|
||||
char addr[8];
|
||||
char addr[5];
|
||||
snprintf(addr, sizeof(addr), "%04" PRIx16, section.org);
|
||||
description = description + "at address $" + addr;
|
||||
} else if (section.isAlignFixed) {
|
||||
char mask[8], offset[8];
|
||||
char mask[5], offset[5];
|
||||
snprintf(mask, sizeof(mask), "%" PRIx16, static_cast<uint16_t>(~section.alignMask));
|
||||
snprintf(offset, sizeof(offset), "%" PRIx16, section.alignOfs);
|
||||
description = description + "with align mask $" + mask + " and offset $" + offset;
|
||||
|
||||
Reference in New Issue
Block a user