[03/11] ir: add_decl_to_scope shouldn't abort on nullptr scopes

Message ID 20240814125649.47119-3-dodji@redhat.com
State New
Headers
Series [01/11] Use smart pointers for variables exported from the ABI corpus |

Commit Message

Dodji Seketeli Aug. 14, 2024, 12:56 p.m. UTC
  From: Dodji Seketeli <dodji@redhat.com>

	* src/abg-ir.cc (add_decl_to_scope): Do not abort on an empty
	scope.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-ir.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index f6d7c527..7d8de813 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -8415,7 +8415,8 @@  scope_decl::~scope_decl()
 decl_base_sptr
 add_decl_to_scope(decl_base_sptr decl, scope_decl* scope)
 {
-  ABG_ASSERT(scope);
+  if (!scope)
+    return decl;
 
   if (scope && decl && !decl->get_scope())
     decl = scope->add_member_decl(decl);