From patchwork Wed Aug 14 12:56:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 95823 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5FE403858427 for ; Wed, 14 Aug 2024 12:57:40 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by sourceware.org (Postfix) with ESMTPS id 3EB14385840A for ; Wed, 14 Aug 2024 12:56:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3EB14385840A Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=seketeli.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3EB14385840A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4b98:dc4:8::225 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723640216; cv=none; b=Cd/Qf3khAclAKFYc9b8qD4VSdsQ0zHmoaYDIaO9lEVVMJDL59bdmL/sbs8BqJHqKL3RVnfw44XByq6cgSdrgZha/N0PoNAsYqJewjvdz5T1m+bXQNHLe0m+vc6zAx4rMcVtE7ez1S/W0C3yaDwP77K3WkmZZxgGaUqIcnbkDFd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723640216; c=relaxed/simple; bh=7Ir25qB8vK53gChN4zGJJeBX94ROHR3IegACX+CkjLo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=PjF1/Z2tLJNfryjkkUSPBEKu3CGqJjWG3NB96WepFGBQRxskch98eaC2oypZwVtcVeZAg3BQprm0W7J+fsd9bRHfAev1Ofx0UDWBK9oz5ekXNpMoz4gc0iqdUzE93H5JHkLzyppG/419v2WiVxRNusj1Jks3ELSTIUEPwf+1fnU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail.gandi.net (Postfix) with ESMTPSA id E3AB11C0008; Wed, 14 Aug 2024 12:56:50 +0000 (UTC) Received: by localhost (Postfix, from userid 1000) id 35B81507A632; Wed, 14 Aug 2024 14:56:49 +0200 (CEST) From: dodji@redhat.com To: libabigail@sourceware.org Cc: dodji@redhat.com Subject: [PATCH 09/11] reader: Avoid crashing on empty scopes in reader::push_decl_to_scope Date: Wed, 14 Aug 2024 14:56:47 +0200 Message-ID: <20240814125649.47119-9-dodji@redhat.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240814125649.47119-1-dodji@redhat.com> References: <20240814125649.47119-1-dodji@redhat.com> MIME-Version: 1.0 X-GND-Sasl: dodj@seketeli.org X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: libabigail@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libabigail-bounces~patchwork=sourceware.org@sourceware.org From: Dodji Seketeli When abixml::reader::push_decl_to_scope gets a nullptr scope, it can sometimes abort. Fixed thus. * src/abg-reader.cc (reader::push_decl_to_scope): It's only if there is a non-nil scope that the assert can be reached. Signed-off-by: Dodji Seketeli --- src/abg-reader.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 2928f3b3..64d16171 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -802,10 +802,12 @@ public: { ABG_ASSERT(decl); if (scope) - add_decl_to_scope(decl, scope); - if (!decl->get_translation_unit()) - decl->set_translation_unit(get_translation_unit()); - ABG_ASSERT(decl->get_translation_unit()); + { + add_decl_to_scope(decl, scope); + if (!decl->get_translation_unit()) + decl->set_translation_unit(get_translation_unit()); + ABG_ASSERT(decl->get_translation_unit()); + } push_decl(decl); }