From 88262ee504cf9b6ad1213453e7c44ad7d098f76a Mon Sep 17 00:00:00 2001 From: packerlschupfer <83344883+packerlschupfer@users.noreply.github.com> Date: Mon, 13 Jul 2026 09:10:33 +0200 Subject: [PATCH] CLI: guard 4 null derefs when loading a 3mf without preset ids (#14580) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CLI: guard 4 null derefs when loading a 3mf with no preset ids At OrcaSlicer.cpp:1700-1704 the post-load block reads printer_settings_id, print_settings_id, filament_settings_id, and nozzle_diameter from the config that the 3mf carries. If the 3mf is a BBL/BBS-flavored 3mf but was produced by a non-GUI writer (e.g. CLI --export-3mf without a loaded preset) any of those keys can be absent, and config.option(...) returns nullptr — the ->value / ->values deref then SIGSEGVs. Wrap each optional lookup in an if-let. printer_model, printer_extruder_variant, and print_extruder_variant already pass create_if_missing=true and are safe. Repro (BEFORE this patch): orca-slicer --export-3mf out.3mf in.stl # produces preset-less 3mf orca-slicer --info out.3mf # SIGSEGV at :1700 bt: __cxx11::basic_string::_M_assign -> Slic3r::CLI::run @ OrcaSlicer.cpp:1700 AFTER: --info out.3mf returns exit 0 with the mesh summary. The same failure mode affected --inspect-mesh, --inspect-paint, and every other action that has to walk the loaded model's config; --slice would only survive because it always injects a printer via --load-settings. --- src/OrcaSlicer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index 311451f774..8cb2c0018c 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -1703,11 +1703,13 @@ int CLI::run(int argc, char **argv) const Vec3d &instance_offset = model_instance->get_offset(); BOOST_LOG_TRIVIAL(info) << boost::format("instance %1% transform {%2%,%3%,%4%} at %5%:%6%")% model_object->name % instance_offset.x() % instance_offset.y() %instance_offset.z() % __FUNCTION__ % __LINE__<< std::endl; }*/ - current_printer_name = config.option("printer_settings_id")->value; - current_process_name = config.option("print_settings_id")->value; + // Read defensively — a 3mf missing preset ids (e.g. one produced + // by a non-GUI writer) would otherwise crash here on the deref. + if (const auto *o = config.option("printer_settings_id")) current_printer_name = o->value; + if (const auto *o = config.option("print_settings_id")) current_process_name = o->value; current_printer_model = config.option("printer_model", true)->value; - current_filaments_name = config.option("filament_settings_id")->values; - current_extruder_count = config.option("nozzle_diameter")->values.size(); + if (const auto *o = config.option("filament_settings_id")) current_filaments_name = o->values; + if (const auto *o = config.option("nozzle_diameter")) current_extruder_count = o->values.size(); current_printer_variant_count = config.option("printer_extruder_variant", true)->values.size(); current_print_variant_count = config.option("print_extruder_variant", true)->values.size(); current_is_multi_extruder = current_extruder_count > 1;