From patchwork Mon Dec 5 14:28:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1712306 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gotplt.org header.i=@gotplt.org header.a=rsa-sha256 header.s=dreamhost header.b=qWqOmoh7; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NQmC02KtPz23p1 for ; Tue, 6 Dec 2022 01:29:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EB55738A90A6 for ; Mon, 5 Dec 2022 14:29:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from donkey.elm.relay.mailchannels.net (donkey.elm.relay.mailchannels.net [23.83.212.49]) by sourceware.org (Postfix) with ESMTPS id A477038A816F for ; Mon, 5 Dec 2022 14:29:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A477038A816F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E61D98213CB for ; Mon, 5 Dec 2022 14:28:54 +0000 (UTC) Received: from pdx1-sub0-mail-a304.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 7F040820DA5 for ; Mon, 5 Dec 2022 14:28:54 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1670250534; a=rsa-sha256; cv=none; b=vIJvcU7l6GlxFfOIQoC/N1opMJAauzhjc3hbc4UJrMB/sDnsjt//KQxa185kgo/lwsbwKY 1VJSS3cudPZGOi5D0R7440R1oloLV7AuqFN8Nc1Lrp0hBaIK8qzmmpgEOcBW/ptzWv5ZEK rOkw93b30lHCm4NcYp8ajQYTS9IBOrHyy6kDVt52O/yWQyofhS+lwfC7pViMT28rFVfZht g290+0570nhLVxVTEuHLzbIwOieDzZIwDXsHbZY/9r0UO3MoH3ebN8r/yGz7RyfAGLDDG0 db8gQ//KOkGfrLyCbKe+QnaXhiaikh4nI4jEEP/ON9L7Dn7/mbtgKqGqomdYrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1670250534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=cnWZV+bQiyNyFWk71DyW/L0YCsumqcXANS6uxJ5W0Fw=; b=B4FejCloBHigm/wmZ2y9jFdwnazkZDbHrLEQg6CXkIzYiiJx9oGh/0u36oqyP8fMYMy3Fv 58IsCJpeocOJwH6jkWXggm2ZluTO1xMHvVE7Go4fBTBTcBOh/3cKjrrZaSbOwnI2uBA4Kk qa1nOWHnm4NlB+xK5kr++0OiLYabsPuyNfUr3OM6bku782relKf03GqXsgNuPqqcfjoL6q uNCxIVHweVJOcb1IzsAstJ4vgNWyVJWPLL+TNdUf+HGu1hhx2wLuXycs5cMUT/FVQwgbkf VTQSnApQOBqqO7/Mb4uM8abi5BcqPsruqhXIRsNDZTjlODirR5izKIgZdpk9aQ== ARC-Authentication-Results: i=1; rspamd-84789cff4b-tqbsp; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Gusty-Illustrious: 581d969800df5bae_1670250534740_3627413341 X-MC-Loop-Signature: 1670250534740:1430356845 X-MC-Ingress-Time: 1670250534740 Received: from pdx1-sub0-mail-a304.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.99.229.54 (trex/6.7.1); Mon, 05 Dec 2022 14:28:54 +0000 Received: from fedora.redhat.com (bras-base-toroon4834w-grc-23-76-68-24-147.dsl.bell.ca [76.68.24.147]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a304.dreamhost.com (Postfix) with ESMTPSA id 4NQmBY6h7Sz9v for ; Mon, 5 Dec 2022 06:28:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1670250534; bh=cnWZV+bQiyNyFWk71DyW/L0YCsumqcXANS6uxJ5W0Fw=; h=From:To:Subject:Date:Content-Transfer-Encoding; b=qWqOmoh7RXUSZkB/eOrWrnVXoIZ9cVB3RC1BzT24ziA/ARWR9aWKJGfGP9VoCylof 5ABxIjRy6JPnuUihCYFFw/o3WD73rnbi6iWd50PMS7c9x1fzeiaJVMGJpvAl2kIFub xTlZXBH1xyar6fQIQAKCbXrT02V6mXq5raKhvQUq5cGHkayHv3UW16US88kfM7gdLQ wStdKo7Ioklrk0PM7BPm1psHHBEZewjwzSzaqNPTZUXqYweR8nGCSUk5OBLgV5X3ql zRvPDunJBptKJTNQQkmqC9DeA/+BiHq1Ht6ajJd4He2i89B7QJCWRYMmXs8vqK2nPW uY9acG8Qckeyw== From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH] testsuite: Fix leaks in tree-dynamic-object-size-0.c Date: Mon, 5 Dec 2022 09:28:50 -0500 Message-Id: <20221205142850.969850-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3037.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" In commit e5cfb9cac1d7aba9a8ea73bfe7922cfaff9d61f3 I introduced tests for strdup and strndup with leaks. Fix those leaks. gcc/testsuite/ChangeLog: * gcc.dg/builtin-dynamic-object-size-0.c (test_strdup, test_strndup, test_strdup_min, test_strndup_min): Free RES before returning from function. --- .../gcc.dg/builtin-dynamic-object-size-0.c | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c index 4f1606a486b..f9047a037d9 100644 --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c @@ -486,7 +486,10 @@ __attribute__ ((noinline)) test_strdup (const char *in) { char *res = __builtin_strdup (in); - return __builtin_dynamic_object_size (res, 0); + size_t sz = __builtin_dynamic_object_size (res, 0); + + __builtin_free (res); + return sz; } size_t @@ -494,7 +497,10 @@ __attribute__ ((noinline)) test_strndup (const char *in, size_t bound) { char *res = __builtin_strndup (in, bound); - return __builtin_dynamic_object_size (res, 0); + size_t sz = __builtin_dynamic_object_size (res, 0); + + __builtin_free (res); + return sz; } size_t @@ -502,7 +508,10 @@ __attribute__ ((noinline)) test_strdup_min (const char *in) { char *res = __builtin_strdup (in); - return __builtin_dynamic_object_size (res, 2); + size_t sz = __builtin_dynamic_object_size (res, 2); + + __builtin_free (res); + return sz; } size_t @@ -510,7 +519,10 @@ __attribute__ ((noinline)) test_strndup_min (const char *in, size_t bound) { char *res = __builtin_strndup (in, bound); - return __builtin_dynamic_object_size (res, 2); + size_t sz = __builtin_dynamic_object_size (res, 2); + + __builtin_free (res); + return sz; } /* Other tests. */