From 535191c1e93015386929cc8f0b20405523057d61 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 5 Nov 2021 15:58:40 +0100 Subject: [PATCH] Verify layerHeight conf value before use --- src/libslic3r/Format/SL1.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Format/SL1.cpp b/src/libslic3r/Format/SL1.cpp index aef8038d6..a8f920ae2 100644 --- a/src/libslic3r/Format/SL1.cpp +++ b/src/libslic3r/Format/SL1.cpp @@ -317,10 +317,16 @@ ConfigSubstitutions import_sla_archive( if (profile_in.empty()) { // missing profile... do guess work // try to recover the layer height from the config.ini which was // present in all versions of sl1 files. - auto lh_str = arch.config.find("layerHeight")->second.data(); - double lh = std::stod(lh_str); // TODO replace with std::from_chars - profile_out.set("layer_height", lh); - profile_out.set("initial_layer_height", lh); + if (auto lh_opt = arch.config.find("layerHeight"); + lh_opt != arch.config.not_found()) + { + auto lh_str = lh_opt->second.data(); + try { + double lh = std::stod(lh_str); // TODO replace with std::from_chars + profile_out.set("layer_height", lh); + profile_out.set("initial_layer_height", lh); + } catch(...) {} + } } // If the archive contains an empty profile, use the one that was passed as output argument