summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2016-06-20 12:11:26 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2016-06-20 12:40:36 +0200
commit6b18e2fb6a9b5a76cec62f2f6b6d9d1ae6ab9d42 (patch)
treec96ed3438190cc3e9fcd2033ea09c83b8e9cd407
parent5807378643e7a590e05c367ce49ede6f0e893c91 (diff)
downloadlibrest-6b18e2fb6a9b5a76cec62f2f6b6d9d1ae6ab9d42.tar.gz
tests/oauth2: Fix 'token' leaks
The string returned from oauth2_proxy_extract_access_token() must be freed. This fixes: ==16342== 27 bytes in 1 blocks are definitely lost in loss record 125 of 278 ==16342== at 0x4C2BBAD: malloc (vg_replace_malloc.c:299) ==16342== by 0x5F5CE58: g_malloc (gmem.c:94) ==16342== by 0x5F75917: g_strndup (gstrfuncs.c:425) ==16342== by 0x56D9BA4: soup_uri_decoded_copy (soup-uri.c:761) ==16342== by 0x4E48C0B: oauth2_proxy_extract_access_token (oauth2-proxy.c:392) ==16342== by 0x400A25: test_access_token_simple (oauth2.c:44) ==16342== by 0x5F7C983: test_case_run (gtestutils.c:2158) ==16342== by 0x5F7C983: g_test_run_suite_internal (gtestutils.c:2241) ==16342== by 0x5F7CB4E: g_test_run_suite_internal (gtestutils.c:2253) ==16342== by 0x5F7CD5D: g_test_run_suite (gtestutils.c:2328) ==16342== by 0x5F7CD80: g_test_run (gtestutils.c:1596) ==16342== by 0x400B64: main (oauth2.c:65) ==16342== ==16342== 27 bytes in 1 blocks are definitely lost in loss record 126 of 278 ==16342== at 0x4C2BBAD: malloc (vg_replace_malloc.c:299) ==16342== by 0x5F5CE58: g_malloc (gmem.c:94) ==16342== by 0x5F75917: g_strndup (gstrfuncs.c:425) ==16342== by 0x56D9BA4: soup_uri_decoded_copy (soup-uri.c:761) ==16342== by 0x4E48C0B: oauth2_proxy_extract_access_token (oauth2-proxy.c:392) ==16342== by 0x400A97: test_url_encoding_access_token (oauth2.c:51) ==16342== by 0x5F7C983: test_case_run (gtestutils.c:2158) ==16342== by 0x5F7C983: g_test_run_suite_internal (gtestutils.c:2241) ==16342== by 0x5F7CB4E: g_test_run_suite_internal (gtestutils.c:2253) ==16342== by 0x5F7CD5D: g_test_run_suite (gtestutils.c:2328) ==16342== by 0x5F7CD80: g_test_run (gtestutils.c:1596) ==16342== by 0x400B64: main (oauth2.c:65)
-rw-r--r--tests/oauth2.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/oauth2.c b/tests/oauth2.c
index 23e609f..12721bc 100644
--- a/tests/oauth2.c
+++ b/tests/oauth2.c
@@ -36,6 +36,7 @@ test_url_fragment_no_access_token ()
char *token = oauth2_proxy_extract_access_token ("http://example.com/foo?foo=1#bar");
g_assert_null (token);
+ g_free (token);
}
static void
@@ -44,6 +45,7 @@ test_access_token_simple ()
char *token = oauth2_proxy_extract_access_token ("http://example.com/foo?foo=1#access_token=1234567890_12.34561abcdefg&bar");
g_assert_cmpstr (token, ==, "1234567890_12.34561abcdefg");
+ g_free (token);
}
static void test_url_encoding_access_token ()
@@ -51,6 +53,7 @@ static void test_url_encoding_access_token ()
char *token = oauth2_proxy_extract_access_token ("http://example.com/foo?foo=1#access_token=1234567890%5F12%2E34561abcdefg&bar");
g_assert_cmpstr (token, ==, "1234567890_12.34561abcdefg");
+ g_free (token);
}
int