From 9c568a543c79aceb2f2d40f7349a49b7c5722e44 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 12 Feb 2021 16:46:49 +0100 Subject: [PATCH] Improving 3MF import: checking for invalid data. --- src/libslic3r/Format/3mf.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index 064a05eb3..64a716508 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -710,6 +710,10 @@ namespace Slic3r { #endif // ENABLE_RELOAD_FROM_DISK_FOR_3MF for (const IdToModelObjectMap::value_type& object : m_objects) { + if (object.second >= m_model->objects.size()) { + add_error("Unable to find object"); + return false; + } ModelObject* model_object = m_model->objects[object.second]; IdToGeometryMap::const_iterator obj_geometry = m_geometries.find(object.first); if (obj_geometry == m_geometries.end()) { @@ -1391,6 +1395,10 @@ namespace Slic3r { { // deletes all non-built or non-instanced objects for (const IdToModelObjectMap::value_type& object : m_objects) { + if (object.second >= m_model->objects.size()) { + add_error("Unable to find object"); + return false; + } ModelObject *model_object = m_model->objects[object.second]; if (model_object != nullptr && model_object->instances.size() == 0) m_model->delete_object(model_object);