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: 29699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2286369wrr; Mon, 5 Dec 2022 06:29:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5MWpd/BxgjgFVcwGy1RByFegyFoWk4QS8+a2KKxNx8H02Pd+NcJE0FhMFvUdpUrdZz+Fm2 X-Received: by 2002:a05:6402:5513:b0:467:7026:515e with SMTP id fi19-20020a056402551300b004677026515emr74735665edb.26.1670250570190; Mon, 05 Dec 2022 06:29:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670250570; cv=pass; d=google.com; s=arc-20160816; b=clpDLeh6va8NRhRTCqra63Q3/0T4JUng78hRcHub4Pv3h/E86oBriOqV7wNlcF5SNE vJk/UOd7OOkIPDE18dPgRedblkfog5YKm1zrNKv3m2bC7/O0ynQ3syu3kfzq3JV7prAy xQbD05IYowfYvQOrItM5kxJQq9V553NYdG2umjE2IYVEsifopHQ365cJ0DIr2ooH7OzF Wxxk1vBOLs1C5t3v94F50pcAjp8WEGhVuznmtRoAJoE4nCBxK8A51b0hHDiKWX41Gkh9 VZkjvBzjXgofnnz9pB5H5bZEnZ1iTg3gQxOs4sajPAEaHcn70+1eqGODOGTDlRoCsFln 2QnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=cnWZV+bQiyNyFWk71DyW/L0YCsumqcXANS6uxJ5W0Fw=; b=XGXxI+5XRLoEfPmdf4EKoM1tc60jOippkkuLbFV5kAfL6TIPaQ5AaI2PJkoec6BoeL wfdiopI3ZY/EXZnCcGUX5pW8fHAuMaLd/H321o8lvPPLp2MHMqYqBzKORfFkAs8DGF1s 8yFPQznHrPoZr6vUZiUwJjbYmmLrIOwiPNYGN2i3zNQHTmD6nJr1lp6IuGkBLgGZ1LjT GB+/wsTB1ZnMD+r9zhJVzqt6WVmOk5yBWN0g+i058a/pNKGRzjzxCATeqNW+Zyi1fmuz d+vlY6bgmUx3bQ9rnRXw+dXpS9RMckikxh5Ein6Ml+rTeVzH7hmEAJzoUMYPdLMFSceQ lJuQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gotplt.org header.s=dreamhost header.b=qWqOmoh7; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id eb5-20020a0564020d0500b0046baedff35bsi13004908edb.291.2022.12.05.06.29.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 06:29:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gotplt.org header.s=dreamhost header.b=qWqOmoh7; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 352B638A90A1 for ; Mon, 5 Dec 2022 14:29:25 +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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751384661862277973?= X-GMAIL-MSGID: =?utf-8?q?1751384661862277973?= 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. */