bfd: Check NULL pointer before setting ref_real
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 5 May 2022 00:00:15 +0000 (17:00 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 5 May 2022 00:57:58 +0000 (17:57 -0700)
PR ld/29086
* linker.c (bfd_wrapped_link_hash_lookup): Check NULL pointer
before setting ref_real.

bfd/linker.c

index e9ebdbad040ebb164f5517c8befc60d46eb021c2..0c2e3c10a67aa335cd019e6a9baab5aa903b1499 100644 (file)
@@ -599,7 +599,8 @@ bfd_wrapped_link_hash_lookup (bfd *abfd,
          n[1] = '\0';
          strcat (n, l + sizeof REAL - 1);
          h = bfd_link_hash_lookup (info->hash, n, create, true, follow);
-         h->ref_real = 1;
+         if (h != NULL)
+           h->ref_real = 1;
          free (n);
          return h;
        }