From 485fd012b4c86e1650391a5aec2b80312749c54e Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 28 Mar 2020 15:28:12 +0000 Subject: [PATCH] Fix segfault in Remove Spline Point context menu This was incorrectly capturing `r` by reference and using it after it left its scope. Changed to capture by value, and also explicitly capture `this` in case we were accidentally capturing any other scope variables by reference. Fixes #571 --- src/mouse.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mouse.cpp b/src/mouse.cpp index c0d1798..6f016d3 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -647,7 +647,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) { int index = r->IndexOfPoint(gs.point[0]); if((r->type == Request::Type::CUBIC && (index > 1 && index < r->extraPoints + 2)) || r->type == Request::Type::CUBIC_PERIODIC) { - menu->AddItem(_("Remove Spline Point"), [&]() { + menu->AddItem(_("Remove Spline Point"), [this, r]() { int index = r->IndexOfPoint(gs.point[0]); ssassert(r->extraPoints != 0, "Expected a bezier with interior control points");