diff --git a/src/ifcparse/parse.cpp b/src/ifcparse/parse.cpp index 9a02b7a4a4..1ee02ecc3f 100644 --- a/src/ifcparse/parse.cpp +++ b/src/ifcparse/parse.cpp @@ -1944,17 +1944,19 @@ void ifcopenshell::instance_streamer::initialize_header() { storage_.schema = schema_; - types_to_bypass_materialized_.resize(schema_->declarations().size(), false); - for (auto& bp : types_to_bypass_) { - std::function mark; - mark = [&](const ifcopenshell::entity* e) { - types_to_bypass_materialized_[e->index_in_schema()] = true; - for (auto& subtype : e->subtypes()) { - mark(subtype); + if (schema_) { + types_to_bypass_materialized_.resize(schema_->declarations().size(), false); + for (auto& bp : types_to_bypass_) { + std::function mark; + mark = [&](const ifcopenshell::entity* e) { + types_to_bypass_materialized_[e->index_in_schema()] = true; + for (auto& subtype : e->subtypes()) { + mark(subtype); + } + }; + if (auto* e = bp->as_entity()) { + mark(e); } - }; - if (auto* e = bp->as_entity()) { - mark(e); } } }