From 5ae9015c82de6f3b5b28f13c581894a770f651be Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Sun, 27 Sep 2026 03:52:29 +0800 Subject: [PATCH] Fix rare crash due to invalid pointer when vector::resize reallocate underlying memory (#15877) --- src/libslic3r/Config.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 6d23ec3770..52b16f9458 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -697,7 +697,8 @@ public: } } else { // Resize by duplicating the last value. - this->values.resize(n, this->values./*back*/front()); + T v = this->values./*back*/front(); + this->values.resize(n, v); } } } @@ -772,8 +773,10 @@ public: if (this->values.empty()) this->values.resize(rhs_vec->size()); - else - this->values.resize(rhs_vec->size(), this->values.front()); + else { + T v = this->values.front(); + this->values.resize(rhs_vec->size(), v); + } assert(default_index.size() == rhs_vec->size());