[lldb/Symbol] Fix null-deref in TypeList::Dump
authorMed Ismail Bennani <medismail.bennani@gmail.com>
Fri, 12 Aug 2022 00:54:41 +0000 (17:54 -0700)
committerMed Ismail Bennani <medismail.bennani@gmail.com>
Fri, 12 Aug 2022 05:29:06 +0000 (22:29 -0700)
This patch should just a crash caused by a null pointer dereferencing
when dumping a type. It makes sure that the pointer is valid.

rdar://97455134

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
lldb/source/Symbol/TypeList.cpp

index 494e59e..2e101e0 100644 (file)
@@ -92,9 +92,9 @@ void TypeList::ForEach(
 }
 
 void TypeList::Dump(Stream *s, bool show_context) {
-  for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
-    pos->get()->Dump(s, show_context);
-  }
+  for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+    if (Type *t = pos->get())
+      t->Dump(s, show_context);
 }
 
 void TypeList::RemoveMismatchedTypes(llvm::StringRef qualified_typename,