From f2bde3228002ba1e23a99c3a86c79f0030908071 Mon Sep 17 00:00:00 2001 From: Seppe Degryse <80254822+Griezn@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:53:13 +0100 Subject: [PATCH] Fixed memory leak in test --- tests/dataTests.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/dataTests.cpp b/tests/dataTests.cpp index 86cbbdc..28b5f75 100644 --- a/tests/dataTests.cpp +++ b/tests/dataTests.cpp @@ -173,16 +173,23 @@ TEST(DataTests, test_file_source_inc) sink_t *gsink = create_generator_sink(); sink_t *fsink = create_generator_sink(); - gsink->push_next(gsink, gsource->get_next(gsource)); - fsink->push_next(fsink, fsource->get_next(fsource)); + data_t *next_gdata = gsource->get_next(gsource); + data_t *next_fdata = fsource->get_next(fsource); + + gsink->push_next(gsink, next_gdata); + fsink->push_next(fsink, next_fdata); ASSERT_TRUE(ARR_EQ(gsink->buffer.data, fsink->buffer.data, increment)); - fsink->push_next(fsink, fsource->get_next(fsource)); + free(next_fdata); + next_fdata = fsource->get_next(fsource); + fsink->push_next(fsink, next_fdata); ASSERT_TRUE(ARR_EQ(gsink->buffer.data + increment, fsink->buffer.data, increment)); - fsink->push_next(fsink, fsource->get_next(fsource)); + free(next_fdata); + next_fdata = fsource->get_next(fsource); + fsink->push_next(fsink, next_fdata); ASSERT_TRUE(ARR_EQ(gsink->buffer.data + 2*increment, fsink->buffer.data, increment));