Fixed crash in generate_parent_id()

This commit is contained in:
David Joslin 2023-11-08 13:31:14 -08:00 committed by Agent X
parent 9d8f8c64a7
commit d824e77cf5
1 changed files with 4 additions and 0 deletions

View File

@ -32,11 +32,15 @@ struct SpawnObjectData {
static u32 generate_parent_id(struct Object* objects[], u8 onIndex, bool sanitize) {
struct Object* o = objects[onIndex];
if (!o) { return (u32)-1; }
// special case if the parent is itself
if (o->parentObj == o) { return (u32)-1; }
if (onIndex == 0) {
if (!o->parentObj) {
return (u32)-1;
}
if (sanitize && o->parentObj->oSyncID == 0) {
return (u32)-1;
}