[libsoup] tests: fix memory leaks in several tests
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] tests: fix memory leaks in several tests
- Date: Fri, 11 Jun 2021 10:25:02 +0000 (UTC)
commit 813ae7ad5480b3c9a656f15e83133d5c268a0190
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Fri Jun 11 12:18:23 2021 +0200
tests: fix memory leaks in several tests
tests/auth-test.c | 2 +-
tests/misc-test.c | 17 +++++++++++++----
tests/request-body-test.c | 10 +++++++---
3 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/tests/auth-test.c b/tests/auth-test.c
index 17fb3e13..05e0f82e 100644
--- a/tests/auth-test.c
+++ b/tests/auth-test.c
@@ -792,7 +792,7 @@ do_async_auth_cancel_test (void)
g_signal_connect (msg, "authenticate",
G_CALLBACK (async_authenticate_cancel_authenticate),
&data);
- soup_test_session_async_send (session, msg, data.cancellable, &error);
+ g_assert_null (soup_test_session_async_send (session, msg, data.cancellable, &error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
g_object_unref (data.auth);
diff --git a/tests/misc-test.c b/tests/misc-test.c
index e32b18f5..3d2e6808 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -260,6 +260,7 @@ do_msg_reuse_test (void)
{
SoupSession *session;
SoupMessage *msg;
+ GBytes *body;
GUri *uri;
guint *signal_ids, n_signal_ids;
@@ -273,26 +274,34 @@ do_msg_reuse_test (void)
msg = soup_message_new_from_uri ("GET", base_uri);
g_signal_connect (msg, "authenticate",
G_CALLBACK (reuse_test_authenticate), NULL);
- soup_test_session_async_send (session, msg, NULL, NULL);
+ body = soup_test_session_async_send (session, msg, NULL, NULL);
+ g_assert_nonnull (body);
ensure_no_signal_handlers (msg, signal_ids, n_signal_ids);
+ g_bytes_unref (body);
debug_printf (1, " Redirect message\n");
uri = g_uri_parse_relative (base_uri, "/redirect", SOUP_HTTP_URI_FLAGS, NULL);
soup_message_set_uri (msg, uri);
g_uri_unref (uri);
- soup_test_session_async_send (session, msg, NULL, NULL);
+ body = soup_test_session_async_send (session, msg, NULL, NULL);
+ g_assert_nonnull (body);
g_assert_true (soup_uri_equal (soup_message_get_uri (msg), base_uri));
ensure_no_signal_handlers (msg, signal_ids, n_signal_ids);
+ g_bytes_unref (body);
debug_printf (1, " Auth message\n");
uri = g_uri_parse_relative (base_uri, "/auth", SOUP_HTTP_URI_FLAGS, NULL);
soup_message_set_uri (msg, uri);
g_uri_unref (uri);
- soup_test_session_async_send (session, msg, NULL, NULL);
+ body = soup_test_session_async_send (session, msg, NULL, NULL);
+ g_assert_nonnull (body);
soup_test_assert_message_status (msg, SOUP_STATUS_OK);
+ g_bytes_unref (body);
soup_message_set_uri (msg, base_uri);
- soup_test_session_async_send (session, msg, NULL, NULL);
+ body = soup_test_session_async_send (session, msg, NULL, NULL);
+ g_assert_nonnull (body);
ensure_no_signal_handlers (msg, signal_ids, n_signal_ids);
+ g_bytes_unref (body);
soup_test_session_abort_unref (session);
g_object_unref (msg);
diff --git a/tests/request-body-test.c b/tests/request-body-test.c
index 1b9938d3..03b28ecb 100644
--- a/tests/request-body-test.c
+++ b/tests/request-body-test.c
@@ -157,9 +157,13 @@ do_request_test (gconstpointer data)
g_signal_connect (msg, "wrote-body",
G_CALLBACK (wrote_body), &ptd);
- if (flags & ASYNC)
- soup_test_session_async_send (session, msg, NULL, NULL);
- else
+ if (flags & ASYNC) {
+ GBytes *body;
+
+ body = soup_test_session_async_send (session, msg, NULL, NULL);
+ g_assert_nonnull (body);
+ g_bytes_unref (body);
+ } else
soup_test_session_send_message (session, msg);
soup_test_assert_message_status (msg, SOUP_STATUS_CREATED);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]