From 6495bd470d40b2b489e6fe350e2da08be64d4bec Mon Sep 17 00:00:00 2001 From: Andreas Nordal Date: Fri, 18 Mar 2016 23:14:16 +0100 Subject: Fix memory leaks at exit found in tests This fixes all memory leaks found by compiling with clang++ -g -fsanitize=address and running the tests. Method: Ensure that memory is freed by the destructor of its respective container, either by storing objects directly instead of by pointer, or implementing the required destructor. --- src/fish_tests.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/fish_tests.cpp') diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index dfc34609..5bacab80 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -2645,9 +2645,11 @@ static void test_universal() if (system("mkdir -p /tmp/fish_uvars_test/")) err(L"mkdir failed"); const int threads = 16; + static int ctx[threads]; for (int i=0; i < threads; i++) { - iothread_perform(test_universal_helper, new int(i)); + ctx[i] = i; + iothread_perform(test_universal_helper, &ctx[i]); } iothread_drain_all(); -- cgit v1.2.3