Fix the same shifting UB for SDAS objects as for RGBDS ones

This commit is contained in:
Rangi
2026-07-14 11:13:30 -04:00
parent ca2de0f429
commit b13b0c8eb8
2 changed files with 4 additions and 8 deletions
+2 -1
View File
@@ -622,7 +622,8 @@ void sdobj_ReadFile(FileStackNode const &src, FILE *file, std::vector<Symbol> &f
);
}
for (uint8_t i = 0; i < nbBaseBytes; ++i) {
baseValue = baseValue | data[offset + i] << (8 * i);
// Cast to `uint32_t` to avoid UB when shifting a byte >= 128 by a count >= 24.
baseValue = baseValue | static_cast<uint32_t>(data[offset + i]) << (8 * i);
}
// Bit 4 specifies signedness, but I don't think that matters?