[01/17] ir: Fix a potential crash in canonicalize_types

Message ID 20240716145541.473065-2-dodji@redhat.com
State New
Headers
Series Support self comparison of vmlinux & modules using BTF/CTF |

Commit Message

Dodji Seketeli July 16, 2024, 2:55 p.m. UTC
  From: Dodji Seketeli <dodji@redhat.com>

I noticed crashes in canonicalize_types when it deals with nullptr
types.  Fixed thus.

	* src/abg-ir-priv.h (canonicalize_types): Avoid crashing when
	de-referencing an iterator to a nullptr type.

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

Patch

diff --git a/src/abg-ir-priv.h b/src/abg-ir-priv.h
index 78a05e72..a9002561 100644
--- a/src/abg-ir-priv.h
+++ b/src/abg-ir-priv.h
@@ -1620,7 +1620,7 @@  canonicalize_types(const input_iterator& begin,
   // First, let's compute the canonical type of this type.
   for (t = begin,i = 0; t != end; ++t, ++i)
     {
-      if (deref(t)->get_environment().priv_->do_log())
+      if (deref(t) && deref(t)->get_environment().priv_->do_log())
 	std::cerr << "#" << std::dec << i << " ";
 
       canonicalize(deref(t));