From 41bfd5b8c2a93b965f2b2928f1ee4335a50e8e6b Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Mon, 18 Aug 2025 09:38:09 +0800 Subject: [PATCH] FIX: CLI: fix the size related issue in set_with_restore_2 jira: no-jira Change-Id: I5b9b5dd3ae2eac63e9f494fd7b7ab5d4d38dbac7 (cherry picked from commit 030ebd1a3515a7d3dbdf3c6cfb77ff0b6b764f2e) --- src/libslic3r/Config.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index ce70f73654..05f6eb8c1c 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -514,11 +514,17 @@ public: //backup original ones std::vector backup_values = this->values; - if (this->values.size() < (start+len)) + if (this->values.size() < start) { throw ConfigurationError("ConfigOptionVector::set_with_restore_2(): invalid size found"); + } + else { + if (this->values.size() < start + len) + len = this->values.size() - start; - //erase the original ones - this->values.erase(this->values.begin() + start, this->values.begin() + start + len); + //erase the original ones + if (len > 0) + this->values.erase(this->values.begin() + start, this->values.begin() + start + len); + } // Assign the new value from the rhs vector. auto other = static_cast*>(rhs);