From d678e6d830c96ae10f7666c3769c87b237d4ea19 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Tue, 1 Mar 2022 12:31:55 +0100 Subject: Test TaskSystem: Fix read after free --- test/buildtool/multithreading/task_system.test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/buildtool/multithreading/task_system.test.cpp') diff --git a/test/buildtool/multithreading/task_system.test.cpp b/test/buildtool/multithreading/task_system.test.cpp index 8488417c..21e1ca6e 100644 --- a/test/buildtool/multithreading/task_system.test.cpp +++ b/test/buildtool/multithreading/task_system.test.cpp @@ -69,8 +69,10 @@ TEST_CASE("Side effects of tasks are reflected out of ts", "[task_system]") { SECTION("Lambda capturing `this` inside struct") { std::string ext_name{}; struct Wrapper { - TaskSystem ts{}; std::string name{}; + // ts must be second, otherwise name will get destroyed before the + // task system is finished. + TaskSystem ts{}; explicit Wrapper(std::string n) : name{std::move(n)} {} -- cgit v1.2.3