[09/11] reader: Avoid crashing on empty scopes in reader::push_decl_to_scope
Commit Message
From: Dodji Seketeli <dodji@redhat.com>
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 <dodji@redhat.com>
---
src/abg-reader.cc | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
@@ -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);
}