diff options
author | Jeremy Linton <jeremy.linton@arm.com> | 2017-04-19 12:24:51 -0500 |
---|---|---|
committer | Daniel Wagner <wagi@monom.org> | 2017-04-24 20:30:52 +0200 |
commit | 1a4b4b18371f4ee4e266e55779db68094e938398 (patch) | |
tree | c8369bb84017b3ea71d8ed574432fc09ea24c601 | |
parent | b4fefa6aa73c46abd6c202af534fd286087f2913 (diff) | |
download | pacrunner-1a4b4b18371f4ee4e266e55779db68094e938398.tar.gz |
unit: Fix test-mozjs memory leak
The mozjs execute calls returns a g_strdup'ed result. This
means that the unit test needs to free the resulting data.
-rw-r--r-- | unit/test-mozjs.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/unit/test-mozjs.c b/unit/test-mozjs.c index 7ccdee9..25c8634 100644 --- a/unit/test-mozjs.c +++ b/unit/test-mozjs.c @@ -93,19 +93,19 @@ static void test_multiple_init(void) static void test_single_execute_without_pac(void) { - const char *result; + char *result; g_assert(mozjs_init() == 0); result = __pacrunner_js_execute(proxy, EXAMPLE_URL, EXAMPLE_HOST); g_test_message("result: %s", result); - + g_free(result); mozjs_exit(); } static void test_multiple_execute_without_pac(void) { - const char *result; + char *result; int i; g_assert(mozjs_init() == 0); @@ -114,6 +114,7 @@ static void test_multiple_execute_without_pac(void) result = __pacrunner_js_execute(proxy, EXAMPLE_URL, EXAMPLE_HOST); g_test_message("result %d: %s", i, result); + g_free(result); } mozjs_exit(); @@ -121,7 +122,7 @@ static void test_multiple_execute_without_pac(void) static void test_single_execute_with_direct_pac(void) { - const char *result; + char *result; g_assert(mozjs_init() == 0); @@ -129,6 +130,7 @@ static void test_single_execute_with_direct_pac(void) result = __pacrunner_js_execute(proxy, EXAMPLE_URL, EXAMPLE_HOST); g_test_message("result: %s", result); + g_free(result); pacrunner_proxy_disable(proxy); @@ -137,7 +139,7 @@ static void test_single_execute_with_direct_pac(void) static void test_multiple_execute_with_direct_pac(void) { - const char *result; + char *result; int i; mozjs_init(); @@ -148,6 +150,7 @@ static void test_multiple_execute_with_direct_pac(void) result = __pacrunner_js_execute(proxy, EXAMPLE_URL, EXAMPLE_HOST); g_test_message("result %d: %s", i, result); + g_free(result); } pacrunner_proxy_disable(proxy); @@ -157,7 +160,7 @@ static void test_multiple_execute_with_direct_pac(void) static void test_massive_execute_with_direct_pac(void) { - const char *result; + char *result; int i; mozjs_init(); @@ -168,6 +171,7 @@ static void test_massive_execute_with_direct_pac(void) result = __pacrunner_js_execute(proxy, EXAMPLE_URL, EXAMPLE_HOST); g_test_message("result %d: %s", i, result); + g_free(result); } pacrunner_proxy_disable(proxy); @@ -177,7 +181,7 @@ static void test_massive_execute_with_direct_pac(void) static void test_multiple_execute_with_example_pac(void) { - const char *result; + char *result; int i; mozjs_init(); @@ -188,6 +192,7 @@ static void test_multiple_execute_with_example_pac(void) result = __pacrunner_js_execute(proxy, EXAMPLE_URL, EXAMPLE_HOST); g_test_message("result %d: %s", i, result); + g_free(result); } pacrunner_proxy_disable(proxy); |