[applied] writer: Avoid sigsev on types with no translation unit

Message ID 8735qff8g6.fsf@redhat.com
State New
Headers
Series [applied] writer: Avoid sigsev on types with no translation unit |

Commit Message

Dodji Seketeli Sept. 8, 2021, 2:28 p.m. UTC
  Hello,

referenced_type_should_be_emitted should not crash on types with
associated translation unit, like e.g, "void type".

Fixed thus.

	* src/abg-writer.cc (referenced_type_should_be_emitted): Don't
	crash on types with no associated translation unit.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.

---
 src/abg-writer.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Patch

diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index f18293dc..4940e755 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -2263,8 +2263,9 @@  referenced_type_should_be_emitted(const type_base *t,
 				  const translation_unit& tu,
 				  bool tu_is_last)
 {
-  if ((tu_is_last || t->get_translation_unit()->get_absolute_path()
-       == tu.get_absolute_path())
+  if ((tu_is_last || (t->get_translation_unit()
+		      && (t->get_translation_unit()->get_absolute_path()
+			  == tu.get_absolute_path())))
       && !ctxt.type_is_emitted(t)
       && !ctxt.decl_only_type_is_emitted(t))
     return true;