Re: stack overflow in debug_write_type
authorAlan Modra <amodra@gmail.com>
Wed, 10 May 2023 13:35:00 +0000 (23:05 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 10 May 2023 13:40:19 +0000 (23:10 +0930)
Apparently u.kindirect->slot can point at a NULL.

* debug.c (debug_write_type): Don't segfault on NULL indirect.

binutils/debug.c

index 5cc77f74906d261e2f336eeb65db2a636cec4805..bb26d9143d0f8031f4d9425dcdf3d02a4e71b6b7 100644 (file)
@@ -2490,7 +2490,8 @@ debug_write_type (struct debug_handle *info,
       return false;
     case DEBUG_KIND_INDIRECT:
       /* Prevent infinite recursion.  */
-      if ((*type->u.kindirect->slot)->mark == info->mark)
+      if (*type->u.kindirect->slot != DEBUG_TYPE_NULL
+         && (*type->u.kindirect->slot)->mark == info->mark)
        return (*fns->empty_type) (fhandle);
       return debug_write_type (info, fns, fhandle, *type->u.kindirect->slot,
                               name);