summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2014-09-02 18:41:50 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2014-09-03 10:23:44 +0200
commit0ad11f04ae8b1285b300170e9f39a45fb5d581ed (patch)
tree9fb81b38a8262b100dddafb70f8032fd6cdf338c
parent75b2da5c7ab481992dec69a7aead04ef3dbb3609 (diff)
downloadlibrest-0ad11f04ae8b1285b300170e9f39a45fb5d581ed.tar.gz
tests/proxy: Fix memory leaks
https://bugzilla.gnome.org/show_bug.cgi?id=735921
-rw-r--r--tests/proxy.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/proxy.c b/tests/proxy.c
index a1bed65..7f97e9c 100644
--- a/tests/proxy.c
+++ b/tests/proxy.c
@@ -152,18 +152,22 @@ echo_test (RestProxy *proxy)
if (rest_proxy_call_get_status_code (call) != SOUP_STATUS_OK) {
g_printerr ("wrong response code\n");
errors++;
+ g_object_unref (call);
return;
}
if (rest_proxy_call_get_payload_length (call) != 6) {
g_printerr ("wrong length returned\n");
errors++;
+ g_object_unref (call);
return;
}
if (g_strcmp0 ("echome", rest_proxy_call_get_payload (call)) != 0) {
g_printerr ("wrong string returned\n");
errors++;
+ g_object_unref (call);
return;
}
+ g_object_unref (call);
}
static void
@@ -187,18 +191,22 @@ reverse_test (RestProxy *proxy)
if (rest_proxy_call_get_status_code (call) != SOUP_STATUS_OK) {
g_printerr ("wrong response code\n");
errors++;
+ g_object_unref (call);
return;
}
if (rest_proxy_call_get_payload_length (call) != 9) {
g_printerr ("wrong length returned\n");
errors++;
+ g_object_unref (call);
return;
}
if (g_strcmp0 ("emesrever", rest_proxy_call_get_payload (call)) != 0) {
g_printerr ("wrong string returned\n");
errors++;
+ g_object_unref (call);
return;
}
+ g_object_unref (call);
}
static void
@@ -206,10 +214,13 @@ status_ok_test (RestProxy *proxy, int status)
{
RestProxyCall *call;
GError *error = NULL;
+ char *status_str;
call = rest_proxy_new_call (proxy);
rest_proxy_call_set_function (call, "status");
- rest_proxy_call_add_param (call, "status", g_strdup_printf ("%d", status));
+ status_str = g_strdup_printf ("%d", status);
+ rest_proxy_call_add_param (call, "status", status_str);
+ g_free (status_str);
if (!rest_proxy_call_run (call, NULL, &error)) {
g_printerr ("Call failed: %s\n", error->message);
@@ -233,10 +244,13 @@ status_error_test (RestProxy *proxy, int status)
{
RestProxyCall *call;
GError *error = NULL;
+ char *status_str;
call = rest_proxy_new_call (proxy);
rest_proxy_call_set_function (call, "status");
- rest_proxy_call_add_param (call, "status", g_strdup_printf ("%d", status));
+ status_str = g_strdup_printf ("%d", status);
+ rest_proxy_call_add_param (call, "status", status_str);
+ g_free (status_str);
if (rest_proxy_call_run (call, NULL, &error)) {
g_printerr ("Call succeeded should have failed");
@@ -244,6 +258,7 @@ status_error_test (RestProxy *proxy, int status)
g_object_unref (call);
return;
}
+ g_error_free (error);
if (rest_proxy_call_get_status_code (call) != status) {
g_printerr ("wrong response code, got %d\n", rest_proxy_call_get_status_code (call));