From patchwork Wed Oct 6 10:02:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12539021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82635C433F5 for ; Wed, 6 Oct 2021 10:02:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 623BA61181 for ; Wed, 6 Oct 2021 10:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237983AbhJFKEc (ORCPT ); Wed, 6 Oct 2021 06:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238044AbhJFKE3 (ORCPT ); Wed, 6 Oct 2021 06:04:29 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6604AC061764 for ; Wed, 6 Oct 2021 03:02:31 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id o20so7096201wro.3 for ; Wed, 06 Oct 2021 03:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NcpHrFgWJ/ELH9PBJYnq/2Qtb68AxKqIsRJrlrd2dV4=; b=UqI20zdBQk8l7OWEM9jjvn1qjgEutdsfSk1Cky6H/na6933Yl15Gk9qFYI8WJKeoPu CmJpNrrfMgokPo/90/OcbIO9fypmPEI+y7fhffkbrCMsId1uPqdwlybRsma9FviJUR2I pzycc5L36ec4UOX2fbpwgNfvIviE+5zLiZWAsEyoMU42BhUecXBONAcss5P/jEXOZcJS MzsK1vAIgVMhbXcmrefCdFxVEWNrr6DATyYRa6AW2Raqfw3ISLpc9c+Nj0MROWJaU1Be Twdu4nCC4Q3nakAfFl1IprobsAb7217YzBjLpzGHW8Ml4IoHtem3U6HHVLGiORmuYjas e+OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NcpHrFgWJ/ELH9PBJYnq/2Qtb68AxKqIsRJrlrd2dV4=; b=UxIdr6G8XfNpBpWPGtebLlMXsXi/3YuCrH6q/qbDu16F6vtC7tE1kr1qXD85GjBurI Y49GVDP8XabUCoDGUAHAkTXpZWEvyUIiJufTdheoFqnmBrTh7HHW4gN/saB27TuwBt9X 5OnKgdyirzlNSGI7M/Of/WvpKVcg7ZLhPv3NNRNmD9SNe5sur4hb3H3fnEMriGGAgkCh S/pX3kLP4gxdU4UiM2lyrQZxJQQkI/79BoI/3P5RtOGWhCjc2CrQuN9dDG+gFfqXRs1v 0HyfWiBO1DS+SziXKrQ02D6DdXyBiKfrcDmzagkRRUz8/QBY0j0j7y5tuYvmsOtAzkTz 8O9w== X-Gm-Message-State: AOAM531QtEFLdcUXxVUqG6w5gZR9MsoW1D9Y1Fe+sP9Sf/s8VMB8jCGs pExF10G5uGto+iN5ti52qjHZEFOFIibGkw== X-Google-Smtp-Source: ABdhPJxDC2qh6wvfsWQjydijgbibuuKr1YK4BM3UgTfWff18sPVa7oI3oPf25DbLvjeRGshy9tlwxQ== X-Received: by 2002:a1c:1b4a:: with SMTP id b71mr8817760wmb.33.1633514549560; Wed, 06 Oct 2021 03:02:29 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id h18sm5515279wmq.23.2021.10.06.03.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 03:02:29 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , =?utf-8?q?Martin_=C3=85gren?= , Andrzej Hunt , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 1/7] tests: fix a memory leak in test-prio-queue.c Date: Wed, 6 Oct 2021 12:02:19 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1441.gbbcdb4c3c66 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak in t/helper/test-prio-queue.c, the lack of freeing the memory with clear_prio_queue() has been there ever since this code was originally added in b4b594a3154 (prio-queue: priority queue of pointers to structs, 2013-06-06). By fixing this leak we can cleanly run t0009-prio-queue.sh under SANITIZE=leak, so annotate it as such with TEST_PASSES_SANITIZE_LEAK=true. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-prio-queue.c | 2 ++ t/t0009-prio-queue.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c index f4028442e37..133b5e6f4ae 100644 --- a/t/helper/test-prio-queue.c +++ b/t/helper/test-prio-queue.c @@ -46,5 +46,7 @@ int cmd__prio_queue(int argc, const char **argv) } } + clear_prio_queue(&pq); + return 0; } diff --git a/t/t0009-prio-queue.sh b/t/t0009-prio-queue.sh index 3941ad25286..eea99107a48 100755 --- a/t/t0009-prio-queue.sh +++ b/t/t0009-prio-queue.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='basic tests for priority queue implementation' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh cat >expect <<'EOF' From patchwork Wed Oct 6 10:02:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12539025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19B0EC4332F for ; Wed, 6 Oct 2021 10:02:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03A8461181 for ; Wed, 6 Oct 2021 10:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237989AbhJFKEd (ORCPT ); Wed, 6 Oct 2021 06:04:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238045AbhJFKE3 (ORCPT ); Wed, 6 Oct 2021 06:04:29 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C8B7C061765 for ; Wed, 6 Oct 2021 03:02:32 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id v17so7061804wrv.9 for ; Wed, 06 Oct 2021 03:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0NyFKyVnHCqw4XdUcSmJBVzDDnnykS+lfVTAXF54LJQ=; b=T2YkS3qhE3D8YXCPL2FvMeeLTHjf8UQQcJTBEvVv+OSViyc1uMG2pPdxyfO0YF3NpF TLC4SN8LGvoz4F/8Li43hMD0wTKGL/uu8PvEE2VdbAiWA9iwaserXmykE1g6WyunRnrX M2XXrB2y7bb4L7qBRZItI58JUcJSGd5av2uUii5POszmItciLNO+HSF56/2PRH7PwFcP T8dHiWIi5cpRK8rv/fDpQIWrJMX1V0T4I3N1Ko1po5CwHgdSDtgzzP0KZ9KFDXqk+iAC +83zA1d9qpYiee8KsonjN2y5eY4q+BxFfHNXZpvC24fgXZnjGZryTfd0/86NtVA5FR5T n4Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0NyFKyVnHCqw4XdUcSmJBVzDDnnykS+lfVTAXF54LJQ=; b=bML0E1Qlwap2+BkgZKTOZtw+5tVSO15S0psl6crc/GvvpSx3Ux2CsyQaw1XKjapHuw 5pHdgOGwJasFCGcekiDJw+u9pQgp37jSCNANDliRWisQlXEXBs2ciUkT1oirzmT57Z23 n1QEFiBXjKN+iejk8uXdSnxAK6URfkotTu3l1ZwU9MlwjJzGnQpxAO7gkiarT3L+se6r pJwg4VPFUnaJD7Ymdjc4wUNopVvlGNKA3FmcjHueRDQCryzxrGJQ4hUB2qmtNIM+EhfS 0LC+Jd/1oxdCy/AylBlOxOLwZW5Kn1sV2uLoMMykG75Z2qwpsV3tP5niUZjc0gkw/11e UHFQ== X-Gm-Message-State: AOAM533Fk1EQlCy8uJmh2Rnn+knBXDF/ljeHTNs+Zu6DAk9p2kHvdT6x n343gwjWXhexqs48q52TOuKbj3KsQO7IDw== X-Google-Smtp-Source: ABdhPJzlzSmwbELN/21tLazxe4MHXztZS5w2NlYsqIZqOYdq1WbgFZsbhy2btNhB9/CQ2MampsN36g== X-Received: by 2002:adf:bb08:: with SMTP id r8mr18173580wrg.247.1633514550365; Wed, 06 Oct 2021 03:02:30 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id h18sm5515279wmq.23.2021.10.06.03.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 03:02:29 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , =?utf-8?q?Martin_=C3=85gren?= , Andrzej Hunt , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 2/7] tests: fix a memory leak in test-parse-options.c Date: Wed, 6 Oct 2021 12:02:20 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1441.gbbcdb4c3c66 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak in t/helper/test-parse-options.c, we were not freeing the allocated "struct string_list" or its items. While I'm at it move the declaration of the "list" string_list the cmd__parse_options() function. In c8ba1639165 (parse-options: add OPT_STRING_LIST helper, 2011-06-09) the "list" variable was added, and later on in c8ba1639165 (parse-options: add OPT_STRING_LIST helper, 2011-06-09) the "expect" was added. The "list" variable was last touched in 2721ce21e43 (use string_list initializer consistently, 2016-06-13), but it was still left at the static scope, it's better to move it to the function for consistency. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-parse-options.c | 7 ++++++- t/t0040-parse-options.sh | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c index a282b6ff13e..48d3cf6692d 100644 --- a/t/helper/test-parse-options.c +++ b/t/helper/test-parse-options.c @@ -14,7 +14,6 @@ static int dry_run = 0, quiet = 0; static char *string = NULL; static char *file = NULL; static int ambiguous; -static struct string_list list = STRING_LIST_INIT_NODUP; static struct { int called; @@ -107,6 +106,8 @@ int cmd__parse_options(int argc, const char **argv) NULL }; struct string_list expect = STRING_LIST_INIT_NODUP; + struct string_list list = STRING_LIST_INIT_NODUP; + struct option options[] = { OPT_BOOL(0, "yes", &boolean, "get a boolean"), OPT_BOOL('D', "no-doubt", &boolean, "begins with 'no-'"), @@ -185,5 +186,9 @@ int cmd__parse_options(int argc, const char **argv) for (i = 0; i < argc; i++) show(&expect, &ret, "arg %02d: %s", i, argv[i]); + expect.strdup_strings = 1; + string_list_clear(&expect, 0); + string_list_clear(&list, 0); + return ret; } diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index da310ed29b1..ed422a1a616 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -5,6 +5,7 @@ test_description='our own option parser' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh cat >expect <<\EOF From patchwork Wed Oct 6 10:02:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12539027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DE9EC433FE for ; Wed, 6 Oct 2021 10:02:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 781F66113E for ; Wed, 6 Oct 2021 10:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238020AbhJFKEe (ORCPT ); Wed, 6 Oct 2021 06:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238047AbhJFKE3 (ORCPT ); Wed, 6 Oct 2021 06:04:29 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04050C061766 for ; Wed, 6 Oct 2021 03:02:33 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id r18so7115244wrg.6 for ; Wed, 06 Oct 2021 03:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HqBxnBdJDc811wYka34z0oCiqNFjsR27o10Wypv7ACE=; b=aB5TKXac35fRqgoRg9YjWRZxnbxjY6ocCHxO3pwpYJ1mnvIb1qQu2a2A7M2qNh1Eys s+Eay1HVxb5MUpq6BRKEPo+3WA7oSq1P8JtQGjb3chDiKfcz2Qr6to/g9ErpXkEvXQbx t+soqHXkrgcCM+ur8xJrOB+5ubcR0mYvOnquLkNWcuz/jbtFYrqb3hHa495lLG8GAiqG npic4bB3EdmoGJUxXOf4lL3Vq02IapZaeoTU5tD6e4FzdVIQNLJZxkL0U2p2Fa+Ei56i 822vkn4tZm6YZZPLvUWAr0wAsAc1qERlYOK7riBvsS/ex7F0NyltzPFnQl/l+2/OO8Jl rzvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HqBxnBdJDc811wYka34z0oCiqNFjsR27o10Wypv7ACE=; b=fz/WwJsJ3x3hjYWFJ1k4apqOcfGknXj723Q/0hS/JpjrDC0T285YJqn1nuEYvYvj3R 1jWNp+zxLmdZth6La+TehfSjsQJ8Vu7ZDRoITFM6QzEPPB0pEHxOazfcyZNX7UwgEeab qxKkrfvxsl1t8Nt8SJd22Cy9qM6DGnNZm37Jzg9hqTftWdJtVjO32xy4Z+iMJvkLR+Nv PPQVfJV93X7Fhqd0Y44MMhNA18KQJUfmRABYp3c7KkOhb1QZNGK4AEOnKPSUtOQ+W6Yr 7Wx3tKbWmGrMCkFgwxY+jSWrSWyigbQrqBDTDVtN/ofgwoSN3p7s1wx7q/rKmAvb5EFh 4VVg== X-Gm-Message-State: AOAM530tybMTcXRY8nsz9WVicGm+js2NBE3yhq9rpc3vkw6bgxhpmHwf xni4vmk3xao0MUcG9S8sW62zxPOtPJAtjQ== X-Google-Smtp-Source: ABdhPJwiEcBpS2PSdUL9y1jOUYmF3gDbAUr4Do8B84DBGqxTjmpL+3n/vJnHLhCXOBAmDVUTl/Zf9Q== X-Received: by 2002:a1c:791a:: with SMTP id l26mr8840496wme.22.1633514551367; Wed, 06 Oct 2021 03:02:31 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id h18sm5515279wmq.23.2021.10.06.03.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 03:02:31 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , =?utf-8?q?Martin_=C3=85gren?= , Andrzej Hunt , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 3/7] tests: fix a memory leak in test-oidtree.c Date: Wed, 6 Oct 2021 12:02:21 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1441.gbbcdb4c3c66 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak in t/helper/test-oidtree.c, we were not freeing the "struct strbuf" we used for the stdin input we parsed. This leak has been here ever since 92d8ed8ac10 (oidtree: a crit-bit tree for odb_loose_cache, 2021-07-07). Now that it's fixed we can declare that t0069-oidtree.sh will pass under GIT_TEST_PASSING_SANITIZE_LEAK=true. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-oidtree.c | 3 +++ t/t0069-oidtree.sh | 1 + 2 files changed, 4 insertions(+) diff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c index 180ee28dd93..d48a409f4e4 100644 --- a/t/helper/test-oidtree.c +++ b/t/helper/test-oidtree.c @@ -45,5 +45,8 @@ int cmd__oidtree(int argc, const char **argv) die("unknown command: %s", line.buf); } } + + strbuf_release(&line); + return 0; } diff --git a/t/t0069-oidtree.sh b/t/t0069-oidtree.sh index bfb1397d7b2..74cc59bf8a7 100755 --- a/t/t0069-oidtree.sh +++ b/t/t0069-oidtree.sh @@ -1,6 +1,7 @@ #!/bin/sh test_description='basic tests for the oidtree implementation' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh maxhexsz=$(test_oid hexsz) From patchwork Wed Oct 6 10:02:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12539031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AB22C433F5 for ; Wed, 6 Oct 2021 10:02:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 053F861152 for ; Wed, 6 Oct 2021 10:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238038AbhJFKEg (ORCPT ); Wed, 6 Oct 2021 06:04:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238051AbhJFKEa (ORCPT ); Wed, 6 Oct 2021 06:04:30 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD04EC061767 for ; Wed, 6 Oct 2021 03:02:33 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id v17so7062026wrv.9 for ; Wed, 06 Oct 2021 03:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZaO+6tYsyXr0rPsymK/LfIGmJktU70aUyeLXVLwjuxk=; b=j8KZzYC3Bh9rAQSOr4rVcGonVnsH3umzBoPUXwrbt0BL6l7cgwy2tTPhQOgPv7/cdu LZnxs4SnQSTpuWvaH368j2H6dNrtbSAdMcFD+ZPEf+z6rh98diJcvKSa54Jy1sCDYhjB gDO1Z+7oDtNpLi1cp1Y65r2hbHwcuKRkqYYZfIkpZlPRDEdlMCZA/1cJn8wy/ViCjQtx b5bfpIfXI0Nio4EiUXpSiTy4I0T60/ZQ0TLRbInfCSOEs2Ig+0cMuVeEPgOBESulvpOC Guaqp0DQpPeqHNqAgQv44RkxC9PS9u0ocvTbjFo8LRYaovRrk5kEE5lhhVo/ACRt25p5 PAGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZaO+6tYsyXr0rPsymK/LfIGmJktU70aUyeLXVLwjuxk=; b=x0dBzeeHeuqz0T5q416dgvMO/VP4rpft3pS2Mh9n22k2K3UEdmKPQCwe2Cykxye21N KxdcvUAMOGs4jy7NW/ffK5rXIlY7VtMm2NSVQqzbbw3y5NaVgSRhMt3F9ysuCuLjV7Dc Z1PERD+IhqXAG9fo/EmMd6yQi+cvFu2ZI8rUvATf53REyvRqKl4I3BSogXkWUIF1dvvB Sn4WMWVYlUsQH+uNuCqZy1iCIWZAV+1nyVmqMpm7Jleby5+L6Ee7G4uU534mavRce8sm WzE0WmpvPr9+uTr6l7Uke4m9Tp1Dg3bu5Dda5+9JNrGaav7EFu6rrXmbENljNo3PrVE4 y4NA== X-Gm-Message-State: AOAM532sNrGgyp/HLXGdX0ZEOArEr5BpUkqbo7Pan04hs64j1ehPXsYN F5UyFHWkb60l5STiF8RN5fDZuIO+yOngLg== X-Google-Smtp-Source: ABdhPJw4wh6Q0pgkOVw/JPa8/nH9AoSDcWhfDfQ7IU3esS1JVxUOIhz087wdlpgInMojZrQ7Gt3HUQ== X-Received: by 2002:a7b:cc96:: with SMTP id p22mr8828975wma.26.1633514552124; Wed, 06 Oct 2021 03:02:32 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id h18sm5515279wmq.23.2021.10.06.03.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 03:02:31 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , =?utf-8?q?Martin_=C3=85gren?= , Andrzej Hunt , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 4/7] tests: fix test-oid-array leak, test in SANITIZE=leak Date: Wed, 6 Oct 2021 12:02:22 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1441.gbbcdb4c3c66 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a trivial memory leak present ever since 38d905bf585 (sha1-array: add test-sha1-array and basic tests, 2014-10-01), now that that's fixed we can test this under GIT_TEST_PASSING_SANITIZE_LEAK=true. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-oid-array.c | 4 ++++ t/t0064-oid-array.sh | 2 ++ 2 files changed, 6 insertions(+) diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c index b16cd0b11b1..d1324d086a2 100644 --- a/t/helper/test-oid-array.c +++ b/t/helper/test-oid-array.c @@ -35,5 +35,9 @@ int cmd__oid_array(int argc, const char **argv) else die("unknown command: %s", line.buf); } + + strbuf_release(&line); + oid_array_clear(&array); + return 0; } diff --git a/t/t0064-oid-array.sh b/t/t0064-oid-array.sh index 2e5438ccdac..88c89e8f48a 100755 --- a/t/t0064-oid-array.sh +++ b/t/t0064-oid-array.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='basic tests for the oid array implementation' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh echoid () { From patchwork Wed Oct 6 10:02:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12539029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40756C433F5 for ; Wed, 6 Oct 2021 10:02:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D257611C3 for ; Wed, 6 Oct 2021 10:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238039AbhJFKEf (ORCPT ); Wed, 6 Oct 2021 06:04:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238049AbhJFKEa (ORCPT ); Wed, 6 Oct 2021 06:04:30 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA638C061768 for ; Wed, 6 Oct 2021 03:02:34 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id m22so7185536wrb.0 for ; Wed, 06 Oct 2021 03:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aVDBHg2ZjgRKkToP/9wPKD6q8rs7xYNR0A4KKhM9PRU=; b=X4/5bAI3FXcDF6BV4aZxPfU6ck5DWvO0LQORoIdIaVEtQavy2zGDmtawl+kPM9D6Fn nFsf5UhMu+MrpOaIlx95O0tHuxizi9EvjjprdFJCRHCCQeyAG9RFr3WnLSlEo4Sk2qku wEm3BarlCt6bPYpvdZVdhcbHmiCYn9x7fzWcrVIWkYVcH8Y1rsT0AQ6n6bcyRrRzyY0X qqwE6sGhIms9Jt9beNfhTmxc/lszix6OnP/VJofn/uktyRgJQx//7etkAQqXNWrIEWi7 5N0bJm0xpgcj+uNOK3j8YVzL+dohff3mXPfEe9YrwsclbEo07Mc4WyG0hxv2/NJ5sI/y PpkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aVDBHg2ZjgRKkToP/9wPKD6q8rs7xYNR0A4KKhM9PRU=; b=Hw8qCJaKItYgxqNwUAnphbqQATc9vBmLYCh6sgPoB1K5lzRFe5PAwsPoydXTJ1bZD+ guNqbOc9GvGHtCwafT3GGPwt1aS41PD54Kvwd0m5XWi4AALPYyzpDt9vuUG0F+hb2jD1 kBgoYBW6i0WZtoxxRajSevtSpRDY9DrJQyf2BDQhIJwf7l4kLhLZJf6P8bsrifwJUs+m r8bBKVoJWGut2k9J32UheSPTCGDWJtDE12s9pnsRhDcpCsXpZKxhaHdA4LaoDj5jB5gt yqv1KiP++19bhIjRuMtPKDkLCmZty9OxT7lhVB6jc1JYRNVCCcP+d/TqTt7w6UpXEqo0 o6AQ== X-Gm-Message-State: AOAM53291osLmS4p585HWY1RQra/W5tFypbVCNrJyZEdisdL5D0Cn7mT oDY7AfH6TlouBqXy64Ou7uTMlEtVMh5pgg== X-Google-Smtp-Source: ABdhPJy4B0/yjO//0HBcol8E4rgNGFL/HLP+mTaGcfho6YJYlhRF2kE4m63Q0Kb/5G66c60DkvhVyA== X-Received: by 2002:adf:8bca:: with SMTP id w10mr17732963wra.43.1633514553116; Wed, 06 Oct 2021 03:02:33 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id h18sm5515279wmq.23.2021.10.06.03.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 03:02:32 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , =?utf-8?q?Martin_=C3=85gren?= , Andrzej Hunt , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 5/7] ls-files: fix a trivial dir_clear() leak Date: Wed, 6 Oct 2021 12:02:23 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1441.gbbcdb4c3c66 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix an edge case that was missed when the dir_clear() call was added in eceba532141 (dir: fix problematic API to avoid memory leaks, 2020-08-18), we need to also clean up when we're about to exit with non-zero. That commit says, on the topic of the dir_clear() API and UNLEAK(): [...]two of them clearly thought about leaks since they had an UNLEAK(dir) directive, which to me suggests that the method to free the data was too unclear. I think that 0e5bba53af7 (add UNLEAK annotation for reducing leak false positives, 2017-09-08) which added the UNLEAK() makes it clear that that wasn't the case, rather it was the desire to avoid the complexity of freeing the memory at the end of the program. This does add a bit of complexity, but I think it's worth it to just fix these leaks when it's easy in built-ins. It allows them to serve as canaries for underlying APIs that shouldn't be leaking, it encourages us to make those freeing APIs nicer for all their users, and it prevents other leaking regressions by being able to mark the entire test as TEST_PASSES_SANITIZE_LEAK=true. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/ls-files.c | 13 +++++-------- t/t3005-ls-files-relative.sh | 1 + t/t3020-ls-files-error-unmatch.sh | 2 ++ t/t3700-add.sh | 1 + t/t7104-reset-hard.sh | 1 + 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/builtin/ls-files.c b/builtin/ls-files.c index e6d415e077a..0fecfa3b0c1 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -674,6 +674,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) N_("suppress duplicate entries")), OPT_END() }; + int ret = 0; if (argc == 2 && !strcmp(argv[1], "-h")) usage_with_options(ls_files_usage, builtin_ls_files_options); @@ -777,16 +778,12 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) if (show_resolve_undo) show_ru_info(the_repository->index); - if (ps_matched) { - int bad; - bad = report_path_error(ps_matched, &pathspec); - if (bad) - fprintf(stderr, "Did you forget to 'git add'?\n"); - - return bad ? 1 : 0; + if (ps_matched && report_path_error(ps_matched, &pathspec)) { + fprintf(stderr, "Did you forget to 'git add'?\n"); + ret = 1; } dir_clear(&dir); free(max_prefix); - return 0; + return ret; } diff --git a/t/t3005-ls-files-relative.sh b/t/t3005-ls-files-relative.sh index 727e9ae1a44..6ba8b589cd0 100755 --- a/t/t3005-ls-files-relative.sh +++ b/t/t3005-ls-files-relative.sh @@ -5,6 +5,7 @@ test_description='ls-files tests with relative paths This test runs git ls-files with various relative path arguments. ' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'prepare' ' diff --git a/t/t3020-ls-files-error-unmatch.sh b/t/t3020-ls-files-error-unmatch.sh index 124e73b8e60..2cbcbc0721b 100755 --- a/t/t3020-ls-files-error-unmatch.sh +++ b/t/t3020-ls-files-error-unmatch.sh @@ -9,6 +9,8 @@ This test runs git ls-files --error-unmatch to ensure it correctly returns an error when a non-existent path is provided on the command line. ' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 4086e1ebbc9..283a66955d6 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -5,6 +5,7 @@ test_description='Test of git add, including the -- option.' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Test the file mode "$1" of the file "$2" in the index. diff --git a/t/t7104-reset-hard.sh b/t/t7104-reset-hard.sh index 7948ec392b3..cf9697eba9a 100755 --- a/t/t7104-reset-hard.sh +++ b/t/t7104-reset-hard.sh @@ -2,6 +2,7 @@ test_description='reset --hard unmerged' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' From patchwork Wed Oct 6 10:02:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12539033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B852C433EF for ; Wed, 6 Oct 2021 10:02:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 340F561181 for ; Wed, 6 Oct 2021 10:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238069AbhJFKEk (ORCPT ); Wed, 6 Oct 2021 06:04:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238002AbhJFKEa (ORCPT ); Wed, 6 Oct 2021 06:04:30 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B379FC06176C for ; Wed, 6 Oct 2021 03:02:35 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id m22so7185641wrb.0 for ; Wed, 06 Oct 2021 03:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OtymzXYeIFxBxo1RMizQW4Mh6UWYuHSgERHeqVA1gWc=; b=UkP/nohkPyLxMoShYhlzurdye50cDzgPQRkiLtN7iLucLhwzdkQ7fdthi02vtE8UFY f3daxmHxoprXD4W74znnoYWO2qgSJpnIFSD6TsKfOkxIx5DGxRmVQu5jEomSEAoApKrd JH1KU2gNCAWcBZLXS8RUH92NzOAwtcPZF1OOEsDDqj44lgiGX0EwbEDqYzJK4Gu/CP3Z YJ+yY7MPI+qoTORaqjTVrEBjzlAC+gRMlFj7EKOjQ59NKKeOtWygD9RiLpAzSMffuH67 e3M+X3AbdrmHbGvYb+1hQIhVtpUjuTVZvP5NUbG827RFRSURnhDXPYkhKW5N+9ydGseX H8Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OtymzXYeIFxBxo1RMizQW4Mh6UWYuHSgERHeqVA1gWc=; b=eMRPtdTBeCpcZezACAEZGLZvrbtgQN6m2iJAFYu12c1Phw4aVvNgErCObFepxIooVg EInQ9U3o3NbM2lO3l4F7jmzBKihx32BBhnPMHz3tt26/QPiSBJSnTBtLvGQlrlazElXI sdnUbOp+1SbAkl98CpgRxnOUtAtuz7peBWBrCqKt1mKDlkmn6zaZgcaEN/Svn+zoHLVY V1o5QjUFub7eArBek2haTStKCYn6oEzgZanrL0dyTFWrEtq9PTkYcnVkSdSdk0mr3zwf yaswl5pmVVsSBupkOJQV4N+yZOwHPFcJGroeeJ6ArE/kON8Xf8YGVcPOP1SGiZi48noA 5YOA== X-Gm-Message-State: AOAM530LHrrA1O84zi8Rs4+E4jYp+yhfEFAHhnEBraD/b18OWS7aRnj9 F1uDfMJXa8PCBDFrmgRVs7UcQM6lRlXCXA== X-Google-Smtp-Source: ABdhPJzjUSXNuif1uSKzPgeEgLVSajswS9WzcFnM1se4+g+m9YbNDgqB/O4SMeTt/Neien5IEOOYgw== X-Received: by 2002:a5d:47ac:: with SMTP id 12mr4139140wrb.352.1633514554051; Wed, 06 Oct 2021 03:02:34 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id h18sm5515279wmq.23.2021.10.06.03.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 03:02:33 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , =?utf-8?q?Martin_=C3=85gren?= , Andrzej Hunt , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 6/7] ls-files: add missing string_list_clear() Date: Wed, 6 Oct 2021 12:02:24 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1441.gbbcdb4c3c66 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been here ever since 72aeb18772d (clean.c, ls-files.c: respect encapsulation of exclude_list_groups, 2013-01-16), we dup'd the argument in option_parse_exclude(), but never freed the string_list. This makes almost all of t3001-ls-files-others-exclude.sh pass (it had a lot of failures before). Let's mark it as passing with TEST_PASSES_SANITIZE_LEAK=true, and then exclude the tests that still failed with a !SANITIZE_LEAK prerequisite check until we fix those leaks. We can still see the failed tests under GIT_TEST_FAIL_PREREQS=true. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/ls-files.c | 1 + t/t3001-ls-files-others-exclude.sh | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 0fecfa3b0c1..6e5ac0780e4 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -783,6 +783,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) ret = 1; } + string_list_clear(&exclude_list, 0); dir_clear(&dir); free(max_prefix); return ret; diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 516c95ea0e8..48cec4e5f88 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -8,6 +8,7 @@ test_description='git ls-files --others --exclude This test runs git ls-files --others and tests --exclude patterns. ' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh rm -fr one three @@ -102,7 +103,7 @@ test_expect_success \ >output && test_cmp expect output' -test_expect_success 'restore gitignore' ' +test_expect_success !SANITIZE_LEAK 'restore gitignore' ' git checkout --ignore-skip-worktree-bits $allignores && rm .git/index ' @@ -125,7 +126,7 @@ cat > expect << EOF # three/ EOF -test_expect_success 'git status honors core.excludesfile' \ +test_expect_success !SANITIZE_LEAK 'git status honors core.excludesfile' \ 'test_cmp expect output' test_expect_success 'trailing slash in exclude allows directory match(1)' ' From patchwork Wed Oct 6 10:02:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12539035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A7A2C433FE for ; Wed, 6 Oct 2021 10:02:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8AD261152 for ; Wed, 6 Oct 2021 10:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238074AbhJFKEm (ORCPT ); Wed, 6 Oct 2021 06:04:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238053AbhJFKEa (ORCPT ); Wed, 6 Oct 2021 06:04:30 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E89CC06176D for ; Wed, 6 Oct 2021 03:02:36 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id u18so7121984wrg.5 for ; Wed, 06 Oct 2021 03:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mcMg4o2t3Otw5CSbZ32t8hz2/CYKOuXHAAVMlElPLl0=; b=HZMqt5HI7VNH++IcLiX8E8ZAagwsMJsgcnG+BWIpSZiDNkzCxTJH/kBvS0CPITB2b+ xeh14eZIPVjpTzrlX6Ulg0g5iKMTseuWrQ7MYa/pUxnP6/34Y56O8shWOPWKpZaXJgCY Uan8iCYeoNvteOQ6VPTDL86skpbvCF/vAEuMFOwmf4UMk2R5lTADlqHzQ4FWIaHHxB4h 6vBumQySn/uhEEDs9mAZ7Zy6pfHWVlQR2QqktX9taCpmMyvhs0yHQ8xquxKfy79Rqg4n SLH+vuoR9wa5/kLM+yF2+UV8YJjbzv8BuP9jN4CMknT8jr6AuARqMFqq9PuKGKXeznSj Kj+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mcMg4o2t3Otw5CSbZ32t8hz2/CYKOuXHAAVMlElPLl0=; b=Nhinr0JosKDwB8+whHaO7obwWEHM/AzvEEByPSoA7ma3SACjL+SN8p63LA5e8cPpuD ZOaU7OmkxeFCK+b8gZSbp/ESodx8XPDmFwC4qtFlOsZU7OxofjLdRPhWpSQU7VNsUKHY hFf+7YIOPiNqX3lZ2K7i38z+wBehLioN+PkNGJqQVEPY0wx7D09ZLqDmBuTpV99oZNCK OR8PH+iO0SGT44AwWA9Ri9ajzlB1iCiOYd+Fq894TL1I9S5UfZF0qofHCQiSTqDhS+Es wWDEZieHMLZ2Ch1QRRkGCfe/M9RipiBxARsPQPz2Dk/7A6t0Nbu+ojmoY++bKrS4V/eN 9A3Q== X-Gm-Message-State: AOAM532R3b/TExs2eaMtex/iYn4Dv8MWqSo+cyzvp2wMDUFPwQ4OrsjG NgiXLZh0V7ec3ARhxlMXw0TqOqcGUPC7PQ== X-Google-Smtp-Source: ABdhPJxV+1+EApbWiyGrUQJYwWUwmt6W3RdQQkQTR0DstJGrMlXHk5+m/bxNsZf4DaFTRGPdcIgVRg== X-Received: by 2002:adf:aad7:: with SMTP id i23mr26379313wrc.209.1633514554822; Wed, 06 Oct 2021 03:02:34 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id h18sm5515279wmq.23.2021.10.06.03.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 03:02:34 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , =?utf-8?q?Martin_=C3=85gren?= , Andrzej Hunt , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 7/7] merge: add missing strbuf_release() Date: Wed, 6 Oct 2021 12:02:25 +0200 Message-Id: X-Mailer: git-send-email 2.33.0.1441.gbbcdb4c3c66 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We strbuf_reset() this "struct strbuf" in a loop earlier, but never freed it. Plugs a memory leak that's been here ever since this code got introduced in 1c7b76be7d6 (Build in merge, 2008-07-07). This takes us from 68 failed tests in "t7600-merge.sh" to 59 under SANITIZE=leak, and makes "t7604-merge-custom-message.sh" pass! Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/merge.c | 2 ++ t/t7604-merge-custom-message.sh | 1 + 2 files changed, 3 insertions(+) diff --git a/builtin/merge.c b/builtin/merge.c index b4bdba2faf6..cd0f0b9e3f2 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1579,6 +1579,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) finish(head_commit, remoteheads, &commit->object.oid, msg.buf); remove_merge_branch_state(the_repository); + strbuf_release(&msg); goto done; } else if (!remoteheads->next && common->next) ; @@ -1749,6 +1750,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) ret = suggest_conflicts(); done: + strbuf_release(&buf); free(branch_to_free); return ret; } diff --git a/t/t7604-merge-custom-message.sh b/t/t7604-merge-custom-message.sh index cd4f9607dc1..eca75551016 100755 --- a/t/t7604-merge-custom-message.sh +++ b/t/t7604-merge-custom-message.sh @@ -4,6 +4,7 @@ test_description='git merge Testing merge when using a custom message for the merge commit.' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh create_merge_msgs() {