From a3e668b6966030b34ae7e3f8f1933f9275f6bf22 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Mon, 15 Jul 2024 12:59:14 +0200 Subject: [PATCH] Fix possible crash To compute the end type, we previously used a lambda function, that was declared static. Thus, the arguments were apparently captured when calling it the first time, and didn't change for subsequent calls. As one of them is a pointer, this could crash if the pointed object had been destroyed in the meantime. Although the minimum fix is just to remove the static for the function, I removed the function itself because it really doesn't make sense anymore in this context. CURA-12042 --- src/geometry/MixedLinesSet.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/geometry/MixedLinesSet.cpp b/src/geometry/MixedLinesSet.cpp index c080becf41..8b0d4a5455 100644 --- a/src/geometry/MixedLinesSet.cpp +++ b/src/geometry/MixedLinesSet.cpp @@ -42,16 +42,17 @@ Shape MixedLinesSet::offset(coord_t distance, ClipperLib::JoinType join_type, do } else { - static auto end_type_fn = [&line, &join_type]() + ClipperLib::EndType end_type; + + if (line->hasClosingSegment()) + { + end_type = ClipperLib::etClosedLine; + } + else { - if (line->hasClosingSegment()) - { - return ClipperLib::etClosedLine; - } - return join_type == ClipperLib::jtMiter ? ClipperLib::etOpenSquare : ClipperLib::etOpenRound; - }; - - const ClipperLib::EndType end_type{ end_type_fn() }; + end_type = (join_type == ClipperLib::jtMiter) ? ClipperLib::etOpenSquare : ClipperLib::etOpenRound; + } + clipper.AddPath(line->getPoints(), join_type, end_type); } }