summaryrefslogtreecommitdiff
path: root/src/factories/DisplayListFactory.cpp
diff options
context:
space:
mode:
authorJeod <47716344+JeodC@users.noreply.github.com>2026-07-21 07:51:22 -0400
committerLywx <kiritodev01@gmail.com>2026-07-21 10:28:15 -0600
commit6e9ee0aaffb6f338551d9fc8fd447e1fe5a03603 (patch)
tree1e7326617ccc92d5d92bebf006d614c8e094354e /src/factories/DisplayListFactory.cpp
parent4c8ef537bffe99e55e2087a4f938f1ddb35de815 (diff)
BK: Add romhack guards for extraction and soundfontctl factory
Diffstat (limited to 'src/factories/DisplayListFactory.cpp')
-rw-r--r--src/factories/DisplayListFactory.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/factories/DisplayListFactory.cpp b/src/factories/DisplayListFactory.cpp
index ce4e77d..2d6d48e 100644
--- a/src/factories/DisplayListFactory.cpp
+++ b/src/factories/DisplayListFactory.cpp
@@ -523,6 +523,16 @@ std::optional<std::shared_ptr<IParsedData>> DListFactory::parse(std::vector<uint
size_t length = 0;
while (processing) {
+ // Some DLs can jump to offsets that never reach a G_ENDDL; stop at
+ // the buffer edge instead of reading past it and synthesize the terminator.
+ if (reader.GetBaseAddress() + 2 * sizeof(uint32_t) > segment.size) {
+ SPDLOG_WARN("DL at 0x{:X} ran off the end of its buffer without G_ENDDL; truncating",
+ GetSafeNode<uint32_t>(node, "offset"));
+ gfxs.push_back(static_cast<uint32_t>(GBI(G_ENDDL)) << 24);
+ gfxs.push_back(0);
+ break;
+ }
+
auto w0 = reader.ReadUInt32();
auto w1 = reader.ReadUInt32();