From 8afd815d98cc25db1063715109957333db1f4574 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 6 Nov 2014 10:40:53 +0000 Subject: tests: Fix a memory leak in test-send-recv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If n_messages ≠ n_valid_messages. --- tests/test-send-recv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test-send-recv.c b/tests/test-send-recv.c index c633655..eac5b91 100644 --- a/tests/test-send-recv.c +++ b/tests/test-send-recv.c @@ -488,8 +488,6 @@ validate_received_messages (TestIOStreamThreadData *data, gsize buffer_offset, message_len_remaining -= valid_len; } test_data->received_bytes += valid_len; - - g_free (buffer->buffer); } g_assert_cmpuint (message->length, <=, total_buf_len); @@ -505,6 +503,18 @@ validate_received_messages (TestIOStreamThreadData *data, gsize buffer_offset, g_assert_cmpuint (message->length, ==, total_buf_len); g_assert (message->from == NULL); + } + + /* Free all messages. */ + for (i = 0; i < (guint) n_messages; i++) { + NiceInputMessage *message = &messages[i]; + guint j; + + for (j = 0; j < (guint) message->n_buffers; j++) { + GInputVector *buffer = &message->buffers[j]; + + g_free (buffer->buffer); + } g_free (message->buffers); } -- cgit v1.2.3