diff --git a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp index 8733e71eadb..9cc9ddea43b 100644 --- a/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp +++ b/kotlin-native/runtime/src/alloc/legacy/cpp/ObjectFactorySweep.hpp @@ -59,7 +59,7 @@ SegregatedFinalizerQueue Sweep( sweepHandle.addSweptObject(); if (HasFinalizers(objHeader)) { auto* extraObject = mm::ExtraObjectData::Get(objHeader); - if (compiler::objcDisposeOnMain() && extraObject->getFlag(mm::ExtraObjectData::FLAGS_RELEASE_ON_MAIN_QUEUE)) { + if (compiler::objcDisposeOnMain() && extraObject && extraObject->getFlag(mm::ExtraObjectData::FLAGS_RELEASE_ON_MAIN_QUEUE)) { objectFactoryIter.MoveAndAdvance(finalizerQueue.mainThread, it); } else { objectFactoryIter.MoveAndAdvance(finalizerQueue.regular, it);