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);