custom levels: fix potential use after free in custom region generation on windows (#4369)

On Windows, the pairs produced by custom regions all become bogus,
probably due to some compiler differences.
Changing the pairs that get stored in the regions to not be pointers
should hopefully resolve this.
To be extra sure, I also pulled some `add_word(0)`s out into locals to
avoid any argument evaluation order shenanigans.

---------

Co-authored-by: Tyler Wilding <xtvaser@gmail.com>
This commit is contained in:
Hat Kid
2026-07-28 03:23:46 +02:00
committed by GitHub
parent a53a526b78
commit f9a4c5b33f
5 changed files with 54 additions and 51 deletions
+6 -3
View File
@@ -116,7 +116,8 @@ void DataObjectGenerator::add_goos_obj(
if (obj.type == goos::ObjectType::INTEGER || obj.type == goos::ObjectType::FLOAT) {
link_word_to_byte(next_slot, current_offset_bytes() + 2);
} else {
link_word_to_byte(add_word(0), current_offset_bytes() + 2);
auto cdr_slot = add_word(0);
link_word_to_byte(cdr_slot, current_offset_bytes() + 2);
}
}
}
@@ -146,7 +147,8 @@ int DataObjectGenerator::add_pair(const goos::Object& obj,
if (current.as_pair()->cdr.is_empty_list()) {
add_empty_list();
} else {
link_word_to_byte(add_word(0), current_offset_bytes() + 2);
auto cdr_slot = add_word(0);
link_word_to_byte(cdr_slot, current_offset_bytes() + 2);
}
} else {
ASSERT_MSG(false, fmt::format("error in pair {}: for {}, entity-actor {} not found",
@@ -164,7 +166,8 @@ int DataObjectGenerator::add_pair(const goos::Object& obj,
if (current.as_pair()->cdr.is_empty_list()) {
add_empty_list();
} else {
link_word_to_byte(add_word(0), current_offset_bytes() + 2);
auto cdr_slot = add_word(0);
link_word_to_byte(cdr_slot, current_offset_bytes() + 2);
}
} else {
ASSERT_MSG(false, fmt::format("error in pair {}: for {}, got invalid id {}",