From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSmSQ-0007mL-2F for qemu-devel@nongnu.org; Thu, 28 Jul 2016 10:38:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSmSL-0000fb-Ss for qemu-devel@nongnu.org; Thu, 28 Jul 2016 10:38:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSmSL-0000fG-KD for qemu-devel@nongnu.org; Thu, 28 Jul 2016 10:38:37 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23A748123A for ; Thu, 28 Jul 2016 14:38:36 +0000 (UTC) From: marcandre.lureau@redhat.com Date: Thu, 28 Jul 2016 18:37:36 +0400 Message-Id: <20160728143808.13707-6-marcandre.lureau@redhat.com> In-Reply-To: <20160728143808.13707-1-marcandre.lureau@redhat.com> References: <20160728143808.13707-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 05/37] tests: fix test-cutils leaks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: eblake@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau Spotted thanks to ASAN. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- tests/test-cutils.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/test-cutils.c b/tests/test-cutils.c index 64e3e95..20b0f59 100644 --- a/tests/test-cutils.c +++ b/tests/test-cutils.c @@ -378,7 +378,7 @@ static void test_qemu_strtol_hex(void) =20 static void test_qemu_strtol_max(void) { - const char *str =3D g_strdup_printf("%ld", LONG_MAX); + char *str =3D g_strdup_printf("%ld", LONG_MAX); char f =3D 'X'; const char *endptr =3D &f; long res =3D 999; @@ -389,6 +389,7 @@ static void test_qemu_strtol_max(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, LONG_MAX); g_assert(endptr =3D=3D str + strlen(str)); + g_free(str); } =20 static void test_qemu_strtol_overflow(void) @@ -497,7 +498,7 @@ static void test_qemu_strtol_full_trailing(void) =20 static void test_qemu_strtol_full_max(void) { - const char *str =3D g_strdup_printf("%ld", LONG_MAX); + char *str =3D g_strdup_printf("%ld", LONG_MAX); long res; int err; =20 @@ -505,6 +506,7 @@ static void test_qemu_strtol_full_max(void) =20 g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, LONG_MAX); + g_free(str); } =20 static void test_qemu_strtoul_correct(void) @@ -662,7 +664,7 @@ static void test_qemu_strtoul_hex(void) =20 static void test_qemu_strtoul_max(void) { - const char *str =3D g_strdup_printf("%lu", ULONG_MAX); + char *str =3D g_strdup_printf("%lu", ULONG_MAX); char f =3D 'X'; const char *endptr =3D &f; unsigned long res =3D 999; @@ -673,6 +675,7 @@ static void test_qemu_strtoul_max(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, ULONG_MAX); g_assert(endptr =3D=3D str + strlen(str)); + g_free(str); } =20 static void test_qemu_strtoul_overflow(void) @@ -776,7 +779,7 @@ static void test_qemu_strtoul_full_trailing(void) =20 static void test_qemu_strtoul_full_max(void) { - const char *str =3D g_strdup_printf("%lu", ULONG_MAX); + char *str =3D g_strdup_printf("%lu", ULONG_MAX); unsigned long res =3D 999; int err; =20 @@ -784,6 +787,7 @@ static void test_qemu_strtoul_full_max(void) =20 g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, ULONG_MAX); + g_free(str); } =20 static void test_qemu_strtoll_correct(void) @@ -941,7 +945,7 @@ static void test_qemu_strtoll_hex(void) =20 static void test_qemu_strtoll_max(void) { - const char *str =3D g_strdup_printf("%lld", LLONG_MAX); + char *str =3D g_strdup_printf("%lld", LLONG_MAX); char f =3D 'X'; const char *endptr =3D &f; int64_t res =3D 999; @@ -952,6 +956,7 @@ static void test_qemu_strtoll_max(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, LLONG_MAX); g_assert(endptr =3D=3D str + strlen(str)); + g_free(str); } =20 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) { =20 - const char *str =3D g_strdup_printf("%lld", LLONG_MAX); + char *str =3D g_strdup_printf("%lld", LLONG_MAX); int64_t res; int err; =20 @@ -1066,6 +1071,7 @@ static void test_qemu_strtoll_full_max(void) =20 g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, LLONG_MAX); + g_free(str); } =20 static void test_qemu_strtoull_correct(void) @@ -1223,7 +1229,7 @@ static void test_qemu_strtoull_hex(void) =20 static void test_qemu_strtoull_max(void) { - const char *str =3D g_strdup_printf("%llu", ULLONG_MAX); + char *str =3D g_strdup_printf("%llu", ULLONG_MAX); char f =3D 'X'; const char *endptr =3D &f; uint64_t res =3D 999; @@ -1234,6 +1240,7 @@ static void test_qemu_strtoull_max(void) g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, ULLONG_MAX); g_assert(endptr =3D=3D str + strlen(str)); + g_free(str); } =20 static void test_qemu_strtoull_overflow(void) @@ -1339,7 +1346,7 @@ static void test_qemu_strtoull_full_trailing(void) =20 static void test_qemu_strtoull_full_max(void) { - const char *str =3D g_strdup_printf("%lld", ULLONG_MAX); + char *str =3D g_strdup_printf("%lld", ULLONG_MAX); uint64_t res =3D 999; int err; =20 @@ -1347,6 +1354,7 @@ static void test_qemu_strtoull_full_max(void) =20 g_assert_cmpint(err, =3D=3D, 0); g_assert_cmpint(res, =3D=3D, ULLONG_MAX); + g_free(str); } =20 static void test_qemu_strtosz_simple(void) --=20 2.9.0