From patchwork Mon Mar 27 11:25:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 75348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1432992vqo; Mon, 27 Mar 2023 04:25:53 -0700 (PDT) X-Google-Smtp-Source: AKy350ZZlAZiwXyLE3Xn/V4SZCpE7Ph5nofiSONL2ppwuaKvgOGKPt/MfqO3LTs9gnTWs6t15NW3 X-Received: by 2002:a17:907:8c83:b0:8b1:7ae9:647 with SMTP id td3-20020a1709078c8300b008b17ae90647mr12316376ejc.76.1679916353253; Mon, 27 Mar 2023 04:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679916353; cv=none; d=google.com; s=arc-20160816; b=RbtjpTnb5t6jZmdg94YpLd0XBaOQYGEsga6sTV8buw3PRjQOf3YoB3mgy7VCUQJG9G ZkxkcVr5s1uRblOrXI8Y8lKKqlX8yFYTHKg9K2kMFXIGJ599FASCkdqMHyqtNfuvBKSz 4XWXknCE2E4A08EEzR1caKFThbaoe7HvHvVXYiT5AkamgC64hqBd/Cw0z0dmEBhtnvuR abGnpRvhW3A6ud2cTCnaYoFlmRpwFgdHHJGPjtTZCYSBck/RbJymN84HpXPRyalzK8lh L4gT9Assu7w4PnRfOXAhjoMRDDSsDKNQt5A1RHN1Ax5tcm8Z3eMjtY3IfqgM6dAo79y5 YfXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=i28zAColzz8rOf+PSuFSQ0AU2GKIBS3w4y4LZm/aCkU=; b=MVrU89T7lR4rJsbL9d9qfVxKvPVRsCt6xL7XT/7YuWZq+4UXMqi35rTpu6hAfj/5m8 wtMgW3f+qKHZwET2PdTbP1RF4X79bNTNOned6oCTxZDijxXJjtv218m/Q+Ki/OD7EvYq yNCqqO2zWNXRnwPGcA2fcy4ERhaHjyJQ5/0T81DUe+NhAzN1/CI7vUfkwBync4zRYgIg ZCG8WqFJ6HrFeidzQmpp3iOWke/tbjOHY+ZNgXZs1COB2jVIfkT5sDX2JpjJ7CAWbC8r zMQT2m/CU+0u7oEaQHH/6t67Nu/dHg8SNmP6XiD6q6xIDVC1bzt+VcR+OjVVZOixDijY H49A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="GfhBmc/3"; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h23-20020a170906261700b0092beae94d7dsi23697764ejc.67.2023.03.27.04.25.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 04:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="GfhBmc/3"; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4DB33858410 for ; Mon, 27 Mar 2023 11:25:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4DB33858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679916351; bh=i28zAColzz8rOf+PSuFSQ0AU2GKIBS3w4y4LZm/aCkU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GfhBmc/3Hf6N4rsAdDb6lN1AiLTR0h1USi/1aIwAZDmJEQyfBU+L/X+31fdQVzijj IdDoF8UwdeWI4o5eHfONi3EYamcYm0vZXxBbI1HUFiAwxo0fm7nD3nCp0wwe0bghsX l+EUDFkqD843OnlMzd/HAbfbzEl2UrfM86bTB5AU= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 7A52A3858D39 for ; Mon, 27 Mar 2023 11:25:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A52A3858D39 Received: by mail-pj1-x1029.google.com with SMTP id qe8-20020a17090b4f8800b0023f07253a2cso8419514pjb.3 for ; Mon, 27 Mar 2023 04:25:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679916343; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i28zAColzz8rOf+PSuFSQ0AU2GKIBS3w4y4LZm/aCkU=; b=A8rWfsKj2gdYOtleFgkp6ADqXP/lm6ycOaieBAhC4N2A2oub/IytXioX6d4IaMjyIC WNU7myHIDXEo5lMD9H6VTXReKzWNz5nStHJNg4/jo+2flWnYk5I7lrd9MokgRv0B4CaA ixnpKYFMBJHOSW078UBnsusP59G5LQZUILyeL95bu9JzEC9WiZh5vlAhx8IUKJRc80+O r9EdP5s2qBHOSY/nMLeCyyq5WDFy2kufISu/BX1PWIngfaqUS/p7ij4zlFgT8F5BSfeq 5k+O8fsa4pUhnIuEZ5FttjfdOP1DMJmBJ/JhOMiATs4nr2YJsZPrPSVGMbbWkrdtwW6I zRkw== X-Gm-Message-State: AO0yUKW391j/NBXFn23AHmf0h8TubeOGybzthqC9z/L+2XkH7NTkK6ZB jO3C5V8dyAYBmRa7dO7X259HJ+UcVn8= X-Received: by 2002:a05:6a20:4999:b0:da:6602:790 with SMTP id fs25-20020a056a20499900b000da66020790mr9902174pzb.52.1679916343372; Mon, 27 Mar 2023 04:25:43 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:1b0:13cb:4f4d:735]) by smtp.gmail.com with ESMTPSA id q17-20020a62ae11000000b0062607d604b2sm18868000pff.53.2023.03.27.04.25.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 04:25:43 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id EA5C9114276F; Mon, 27 Mar 2023 21:55:40 +1030 (ACDT) Date: Mon, 27 Mar 2023 21:55:40 +1030 To: binutils@sourceware.org Subject: Duplicate DW_AT_call_file leak Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3034.1 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761519970192029180?= X-GMAIL-MSGID: =?utf-8?q?1761519970192029180?= From 10626d8e35a00e26dec4abb276052ed197545cc6 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 26 Mar 2023 18:49:13 +1030 Subject: When given two or more DW_AT_call_file for a given function we currently leak the concat memory. * dwarf2.c (scan_unit_for_symbols): Don't leak on duplicate DW_AT_call_file. diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 15862dc2037..d99508a96c7 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -4083,8 +4083,11 @@ scan_unit_for_symbols (struct comp_unit *unit) { case DW_AT_call_file: if (is_int_form (&attr)) - func->caller_file = concat_filename (unit->line_table, - attr.u.val); + { + free (func->caller_file); + func->caller_file = concat_filename (unit->line_table, + attr.u.val); + } break; case DW_AT_call_line: