diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-07-07 20:43:40 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-09-08 17:57:32 +0400 |
commit | d6f723b513a0c3c4e58343b7c52a2f9850861fa0 (patch) | |
tree | ea39218439de8e178c6683291ba54218ea2d356c /tests | |
parent | 3e3e302ff388669d811077248aee45c45a14168e (diff) | |
download | qemu-d6f723b513a0c3c4e58343b7c52a2f9850861fa0.zip |
tests: fix test-cutils leaks
Spotted thanks to ASAN.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-cutils.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/test-cutils.c b/tests/test-cutils.c index 64e3e95ce2..20b0f59ba2 100644 --- a/tests/test-cutils.c +++ b/tests/test-cutils.c @@ -378,7 +378,7 @@ static void test_qemu_strtol_hex(void) static void test_qemu_strtol_max(void) { - const char *str = g_strdup_printf("%ld", LONG_MAX); + char *str = g_strdup_printf("%ld", LONG_MAX); char f = 'X'; const char *endptr = &f; long res = 999; @@ -389,6 +389,7 @@ static void test_qemu_strtol_max(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LONG_MAX); g_assert(endptr == str + strlen(str)); + g_free(str); } static void test_qemu_strtol_overflow(void) @@ -497,7 +498,7 @@ static void test_qemu_strtol_full_trailing(void) static void test_qemu_strtol_full_max(void) { - const char *str = g_strdup_printf("%ld", LONG_MAX); + char *str = g_strdup_printf("%ld", LONG_MAX); long res; int err; @@ -505,6 +506,7 @@ static void test_qemu_strtol_full_max(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LONG_MAX); + g_free(str); } static void test_qemu_strtoul_correct(void) @@ -662,7 +664,7 @@ static void test_qemu_strtoul_hex(void) static void test_qemu_strtoul_max(void) { - const char *str = g_strdup_printf("%lu", ULONG_MAX); + char *str = g_strdup_printf("%lu", ULONG_MAX); char f = 'X'; const char *endptr = &f; unsigned long res = 999; @@ -673,6 +675,7 @@ static void test_qemu_strtoul_max(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, ULONG_MAX); g_assert(endptr == str + strlen(str)); + g_free(str); } static void test_qemu_strtoul_overflow(void) @@ -776,7 +779,7 @@ static void test_qemu_strtoul_full_trailing(void) static void test_qemu_strtoul_full_max(void) { - const char *str = g_strdup_printf("%lu", ULONG_MAX); + char *str = g_strdup_printf("%lu", ULONG_MAX); unsigned long res = 999; int err; @@ -784,6 +787,7 @@ static void test_qemu_strtoul_full_max(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, ULONG_MAX); + g_free(str); } static void test_qemu_strtoll_correct(void) @@ -941,7 +945,7 @@ static void test_qemu_strtoll_hex(void) static void test_qemu_strtoll_max(void) { - const char *str = g_strdup_printf("%lld", LLONG_MAX); + char *str = g_strdup_printf("%lld", LLONG_MAX); char f = 'X'; const char *endptr = &f; int64_t res = 999; @@ -952,6 +956,7 @@ static void test_qemu_strtoll_max(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LLONG_MAX); g_assert(endptr == str + strlen(str)); + g_free(str); } static void test_qemu_strtoll_overflow(void) @@ -1058,7 +1063,7 @@ static void test_qemu_strtoll_full_trailing(void) static void test_qemu_strtoll_full_max(void) { - const char *str = g_strdup_printf("%lld", LLONG_MAX); + char *str = g_strdup_printf("%lld", LLONG_MAX); int64_t res; int err; @@ -1066,6 +1071,7 @@ static void test_qemu_strtoll_full_max(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, LLONG_MAX); + g_free(str); } static void test_qemu_strtoull_correct(void) @@ -1223,7 +1229,7 @@ static void test_qemu_strtoull_hex(void) static void test_qemu_strtoull_max(void) { - const char *str = g_strdup_printf("%llu", ULLONG_MAX); + char *str = g_strdup_printf("%llu", ULLONG_MAX); char f = 'X'; const char *endptr = &f; uint64_t res = 999; @@ -1234,6 +1240,7 @@ static void test_qemu_strtoull_max(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, ULLONG_MAX); g_assert(endptr == str + strlen(str)); + g_free(str); } static void test_qemu_strtoull_overflow(void) @@ -1339,7 +1346,7 @@ static void test_qemu_strtoull_full_trailing(void) static void test_qemu_strtoull_full_max(void) { - const char *str = g_strdup_printf("%lld", ULLONG_MAX); + char *str = g_strdup_printf("%lld", ULLONG_MAX); uint64_t res = 999; int err; @@ -1347,6 +1354,7 @@ static void test_qemu_strtoull_full_max(void) g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, ULLONG_MAX); + g_free(str); } static void test_qemu_strtosz_simple(void) |