From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id C3D58385141E for ; Wed, 9 Sep 2020 08:22:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C3D58385141E Received: by mail-pf1-x431.google.com with SMTP id x123so1497963pfc.7 for ; Wed, 09 Sep 2020 01:22:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=zjMk5qPNtj1yXETlIGFpi1HFVB0XZ6OqfDgJIPAoL/s=; b=MKm8zQP99+lNs75fKK6e1z12SPTdRT0HdA//g+ZQUkF21iWUhDjHZxtyJjnxPnUN+W 7TJ6Cn8XvqKT1q6wi5jfXZ8pFOfHZnUhmjnUcAWY/tPIKSU3O/hUfpbNi1lEaikuQtzL 4qpGvEv4HSx3Td/pM4G4AYGuRSRzz1DRVgQjplJLQFXEpVO71Xv6t3Vl90e0ZlzCUCh8 yjZKfHjfNiGO+8dfruxWDYMuxv9pI6pLK60YLUVEGbY/d4acj7UgoDavHJrFPcsXxwZp a5y57Nw/vgZ6pBrllgUTQghp+4bm4Fn/Iq46w0kTi1avKEWGIBVnTdLQMT9bny0Ci4Yt SeCw== X-Gm-Message-State: AOAM5337eyqHXS/NyXcL31UVbL1Ne9gMqO83DPlSyfxdH5PBwefZULrY o6vRjwgxx5u47vX0dZH2bMM4GoorMUs= X-Google-Smtp-Source: ABdhPJw9mNxGohe1rdj22IvaawQIBPFLJvSfAc8fUW6ABY/AGugmGO3TMHpqLdiU274KsnTRtEG+qw== X-Received: by 2002:a17:902:9a06:b029:d0:cb2d:f276 with SMTP id v6-20020a1709029a06b02900d0cb2df276mr2961910plp.15.1599639741441; Wed, 09 Sep 2020 01:22:21 -0700 (PDT) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id y195sm1824354pfc.137.2020.09.09.01.22.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 01:22:20 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id BCD1486AE7; Wed, 9 Sep 2020 17:52:16 +0930 (ACST) Date: Wed, 9 Sep 2020 17:52:16 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR26578, memory leak in parse_gnu_debugaltlink Message-ID: <20200909082216.GC15695@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2020 08:22:24 -0000 The associated check function doesn't do anything with its "data" param, so nothing to adjust there. PR 26578 * dwarf.c (parse_gnu_debugaltlink): Don't alloc build_id_data. (load_separate_debug_files): Use a stack var for build_id_data. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 616e534849..9c141b1776 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -10353,15 +10353,10 @@ parse_gnu_debugaltlink (struct dwarf_section * section, void * data) if (id_len < 0x14) return NULL; - build_id_data = calloc (1, sizeof * build_id_data); - if (build_id_data == NULL) - return NULL; - + build_id_data = (Build_id_data *) data; build_id_data->len = id_len; build_id_data->data = section->start + namelen; - * (Build_id_data **) data = build_id_data; - return name; } @@ -10750,7 +10745,7 @@ load_separate_debug_files (void * file, const char * filename) if (load_debug_section (gnu_debugaltlink, file)) { - Build_id_data * build_id_data; + Build_id_data build_id_data; load_separate_debug_info (filename, & debug_displays[gnu_debugaltlink].section, -- Alan Modra Australia Development Lab, IBM