From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 8F1003858D3C for ; Fri, 18 Mar 2022 15:08:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F1003858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from tarox.wildebeest.org (83-87-18-245.cable.dynamic.v4.ziggo.nl [83.87.18.245]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 1D737302FB81; Fri, 18 Mar 2022 16:08:38 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id EADBA413CEB2; Fri, 18 Mar 2022 16:08:35 +0100 (CET) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: david korczynski , Mark Wielaard Subject: [PATCH] libdwfl: Close ar members when they cannot be processed. Date: Fri, 18 Mar 2022 16:08:25 +0100 Message-Id: <20220318150825.4811-1-mark@klomp.org> X-Mailer: git-send-email 2.18.4 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2022 15:08:46 -0000 When reporting ar members they should be closed when they cannot be processed. A comment in offline.c said that process_file called elf_end if it returned NULL. But this is incorrect. And other places that call process_file do call elf_end explicitly when it returns NULL. Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog | 5 +++++ libdwfl/offline.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index b2588b12..182f4e34 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2022-02-18 Mark Wielaard + + * offline.c (process_archive_member): Close member if process_file + failed. + 2022-01-03 Mark Wielaard * link_map.c (dwfl_link_map_report): Only declare d32 and d64 before diff --git a/libdwfl/offline.c b/libdwfl/offline.c index d8697cf2..58ba4c36 100644 --- a/libdwfl/offline.c +++ b/libdwfl/offline.c @@ -1,5 +1,6 @@ /* Recover relocatibility for addresses computed from debug information. Copyright (C) 2005-2009, 2012 Red Hat, Inc. + Copyright (C) 2022 Mark J. Wielaard This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -233,8 +234,11 @@ process_archive_member (Dwfl *dwfl, const char *name, const char *file_name, free (member_name); free (module_name); - if (*mod == NULL) /* process_file called elf_end. */ - return ELF_C_NULL; + if (*mod == NULL) + { + elf_end (member); + return ELF_C_NULL; + } /* Advance the archive-reading offset for the next iteration. */ return elf_next (member); -- 2.18.4