diff options
author | Dan Winship <danw@gnome.org> | 2012-12-11 17:34:06 +0100 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-12-11 17:34:06 +0100 |
commit | db084cb64d226afc8489386c7e3f45e6f584e43c (patch) | |
tree | 3b8fac70eaa6239928d87348850e4abae2d3d8ef | |
parent | a2a4fccfa8ebd09aea232913eaa3bf1752038e40 (diff) | |
download | libsoup-db084cb64d226afc8489386c7e3f45e6f584e43c.tar.gz libsoup-db084cb64d226afc8489386c7e3f45e6f584e43c.tar.bz2 libsoup-db084cb64d226afc8489386c7e3f45e6f584e43c.zip |
tests: fix memory leaks
-rw-r--r-- | tests/libsoup.supp | 13 | ||||
-rw-r--r-- | tests/multipart-test.c | 19 | ||||
-rw-r--r-- | tests/redirect-test.c | 2 | ||||
-rw-r--r-- | tests/sniffing-test.c | 8 |
4 files changed, 37 insertions, 5 deletions
diff --git a/tests/libsoup.supp b/tests/libsoup.supp index ac21e96a..ae8bda38 100644 --- a/tests/libsoup.supp +++ b/tests/libsoup.supp @@ -401,6 +401,19 @@ ... fun:thread_memory_from_self } +{ + glib/gobjectinit + Memcheck:Leak + ... + fun:gobject_init_ctor +} +{ + glib/gtask threadpool + Memcheck:Leak + ... + fun:g_thread_pool_new + fun:g_task_thread_pool_init +} # probably inlines the aggressive memcpy/memcmp { diff --git a/tests/multipart-test.c b/tests/multipart-test.c index 8bcc4cd4..a9b3425d 100644 --- a/tests/multipart-test.c +++ b/tests/multipart-test.c @@ -130,16 +130,19 @@ read_cb (GObject *source, GAsyncResult *asyncResult, gpointer data) GInputStream *stream = G_INPUT_STREAM (source); GError *error = NULL; gssize bytes_read = g_input_stream_read_finish (stream, asyncResult, &error); + if (error) { debug_printf (1, " failed read: %s\n", error->message); errors++; + g_object_unref (stream); g_main_loop_quit (loop); return; } if (!bytes_read) { g_input_stream_close (stream, NULL, &error); + g_object_unref (stream); if (error) { debug_printf (1, " failed close: %s\n", error->message); @@ -246,6 +249,7 @@ multipart_read_cb (GObject *source, GAsyncResult *asyncResult, gpointer data) g_input_stream_close_async (in, G_PRIORITY_DEFAULT, NULL, multipart_close_part_cb, NULL); + g_object_unref (in); g_main_loop_quit (loop); return; @@ -259,6 +263,7 @@ multipart_read_cb (GObject *source, GAsyncResult *asyncResult, gpointer data) g_input_stream_close_async (in, G_PRIORITY_DEFAULT, NULL, multipart_close_part_cb, NULL); + g_object_unref (in); soup_multipart_input_stream_next_part_async (multipart, G_PRIORITY_DEFAULT, NULL, multipart_next_part_cb, data); @@ -362,8 +367,10 @@ multipart_next_part_cb (GObject *source, GAsyncResult *res, gpointer data) if (error) { debug_printf (1, " failed next part: %s\n", error->message); + g_clear_error (&error); errors++; + g_object_unref (multipart); g_main_loop_quit (loop); return; } @@ -374,6 +381,7 @@ multipart_next_part_cb (GObject *source, GAsyncResult *res, gpointer data) errors++; } + g_object_unref (multipart); g_main_loop_quit (loop); return; } @@ -400,6 +408,8 @@ multipart_handling_cb (GObject *source, GAsyncResult *res, gpointer data) in = soup_request_send_finish (request, res, &error); message = soup_request_http_get_message (SOUP_REQUEST_HTTP (request)); multipart = soup_multipart_input_stream_new (message, in); + g_object_unref (message); + g_object_unref (in); if (error) { debug_printf (1, " failed send: %s\n", error->message); @@ -430,6 +440,8 @@ sync_multipart_handling_cb (GObject *source, GAsyncResult *res, gpointer data) in = soup_request_send_finish (request, res, &error); message = soup_request_http_get_message (SOUP_REQUEST_HTTP (request)); multipart = soup_multipart_input_stream_new (message, in); + g_object_unref (message); + g_object_unref (in); if (error) { debug_printf (1, " failed send: %s\n", error->message); @@ -460,12 +472,14 @@ sync_multipart_handling_cb (GObject *source, GAsyncResult *res, gpointer data) debug_printf (1, " failed sync read: %s\n", error->message); errors++; g_clear_error (&error); + g_object_unref (in); break; } check_read (bytes_read, passes); passes++; + g_object_unref (in); } if (passes != 4) { @@ -474,7 +488,7 @@ sync_multipart_handling_cb (GObject *source, GAsyncResult *res, gpointer data) } g_main_loop_quit (loop); - + g_object_unref (multipart); } static const char* @@ -519,8 +533,6 @@ test_multipart (int headers_expected, int sniffed_expected, MultipartMode multip g_signal_connect (msg, "content-sniffed", G_CALLBACK (content_sniffed), &sniffed_count); - g_object_ref (msg); - if (multipart_mode == ASYNC_MULTIPART) soup_request_send_async (request, NULL, multipart_handling_cb, loop); else if (multipart_mode == ASYNC_MULTIPART_SMALL_READS) { @@ -599,6 +611,7 @@ main (int argc, char **argv) soup_uri_free (base_uri); g_free (base_uri_string); + g_free (buffer); soup_test_session_abort_unref (session); soup_test_server_quit_unref (server); diff --git a/tests/redirect-test.c b/tests/redirect-test.c index f820d003..3307ce63 100644 --- a/tests/redirect-test.c +++ b/tests/redirect-test.c @@ -270,6 +270,7 @@ do_request_api_test (SoupSession *session, SoupURI *base_uri, int n) } g_error_free (error); + g_object_unref (msg); g_object_unref (reqh); debug_printf (2, "\n"); return; @@ -277,6 +278,7 @@ do_request_api_test (SoupSession *session, SoupURI *base_uri, int n) debug_printf (1, " could not send request: %s\n", error->message); g_error_free (error); + g_object_unref (msg); g_object_unref (reqh); errors++; debug_printf (2, "\n"); diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c index e77154e1..ab8099da 100644 --- a/tests/sniffing-test.c +++ b/tests/sniffing-test.c @@ -384,8 +384,10 @@ test_sniffing (const char *path, const char *expected_type) req = soup_session_request_uri (session, uri, NULL); stream = soup_test_request_send (req, NULL, &error); - if (stream) + if (stream) { soup_test_request_close_stream (req, stream, NULL, &error); + g_object_unref (stream); + } if (error) { debug_printf (1, " request failed: %s\n", error->message); g_clear_error (&error); @@ -436,8 +438,10 @@ test_disabled (const char *path) req = soup_session_request_uri (session, uri, NULL); soup_request_disable_feature (req, SOUP_TYPE_CONTENT_SNIFFER); stream = soup_test_request_send (req, NULL, &error); - if (stream) + if (stream) { soup_test_request_close_stream (req, stream, NULL, &error); + g_object_unref (stream); + } if (error) { debug_printf (1, " request failed: %s\n", error->message); g_clear_error (&error); |