From 7fa6be6a25d3fd14fe4343bf46427e136e4fb13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 28 Sep 2026 09:06:35 -0600 Subject: [PATCH] Serialize: Don't dereference unfilled pointers after a load fails Containers of pointers are filled with nullptr and then DoClass'd, and once an error switches the load to MODE_NOOP, every remaining element called DoState on null. Co-Authored-By: Claude Opus 5.5 (1M context) --- Common/Serialize/SerializeFuncs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Common/Serialize/SerializeFuncs.h b/Common/Serialize/SerializeFuncs.h index c8c8eb4b33..49fcded674 100644 --- a/Common/Serialize/SerializeFuncs.h +++ b/Common/Serialize/SerializeFuncs.h @@ -66,6 +66,9 @@ void DoClass(PointerWrap &p, T *&x) { if (p.mode == PointerWrap::MODE_READ) { delete x; x = new T(); + } else if (p.mode == PointerWrap::MODE_NOOP && !x) { + // A load that failed partway leaves the rest of a container unfilled. + return; } x->DoState(p); } @@ -76,6 +79,8 @@ void DoSubClass(PointerWrap &p, T *&x, Args... args) { if (x != nullptr) delete x; x = new S(args...); + } else if (p.mode == PointerWrap::MODE_NOOP && !x) { + return; } x->DoState(p); }