From e641903b16764da757039dd07dd5952bcb82fbbd Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Sun, 22 Oct 2023 06:35:53 -0500 Subject: [PATCH] Fix crash when referencing an invalid variable name (#2486) Fix crash when referencing an invalid variable name using the old placeholder parser syntax --- src/libslic3r/PlaceholderParser.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/PlaceholderParser.cpp b/src/libslic3r/PlaceholderParser.cpp index 2a8d7229c2..22ef3705d8 100644 --- a/src/libslic3r/PlaceholderParser.cpp +++ b/src/libslic3r/PlaceholderParser.cpp @@ -810,9 +810,12 @@ namespace client const ConfigOption *opt = ctx->resolve_symbol(opt_key_str); if (opt == nullptr) { // Check whether the opt_key ends with '_'. - if (opt_key_str.back() == '_') + if (opt_key_str.back() == '_') { opt_key_str.resize(opt_key_str.size() - 1); - opt = ctx->resolve_symbol(opt_key_str); + opt = ctx->resolve_symbol(opt_key_str); + } + if (opt == nullptr) + ctx->throw_exception("Variable does not exist", opt_key); } if (! opt->is_vector()) ctx->throw_exception("Trying to index a scalar variable", opt_key);