From patchwork Tue Sep 6 12:26:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 9316569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 446A260752 for ; Tue, 6 Sep 2016 12:36:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33EC028766 for ; Tue, 6 Sep 2016 12:36:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 286B128D03; Tue, 6 Sep 2016 12:36:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B5EB828766 for ; Tue, 6 Sep 2016 12:36:26 +0000 (UTC) Received: from localhost ([::1]:33067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhFc1-0001ls-Tl for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Sep 2016 08:36:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhFSz-0002Va-Cw for qemu-devel@nongnu.org; Tue, 06 Sep 2016 08:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhFSt-00016E-J3 for qemu-devel@nongnu.org; Tue, 06 Sep 2016 08:27:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43724) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhFSt-000168-Aq for qemu-devel@nongnu.org; Tue, 06 Sep 2016 08:26:59 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 EED9943A34; Tue, 6 Sep 2016 12:26:58 +0000 (UTC) Received: from localhost (ovpn-116-72.phx2.redhat.com [10.3.116.72]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u86CQuJT008454; Tue, 6 Sep 2016 08:26:58 -0400 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Tue, 6 Sep 2016 16:26:18 +0400 Message-Id: <20160906122639.11163-6-marcandre.lureau@redhat.com> In-Reply-To: <20160906122639.11163-1-marcandre.lureau@redhat.com> References: <20160906122639.11163-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 06 Sep 2016 12:26:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/26] tests: fix test-cutils leaks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, armbru@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Spotted thanks to ASAN. Signed-off-by: Marc-André 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) 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)