asan: null deref in coff_write_relocs

* coffcode.h (coff_write_relocs): Don't deref NULL howto.
This commit is contained in:
Alan Modra
2022-06-02 16:31:42 +09:30
parent e0ad09cfa5
commit f66d30a6e5

View File

@ -2690,8 +2690,10 @@ coff_write_relocs (bfd * abfd, int first_undef)
#ifdef SELECT_RELOC #ifdef SELECT_RELOC
/* Work out reloc type from what is required. */ /* Work out reloc type from what is required. */
if (q->howto)
SELECT_RELOC (n, q->howto); SELECT_RELOC (n, q->howto);
#else #else
if (q->howto)
n.r_type = q->howto->type; n.r_type = q->howto->type;
#endif #endif
coff_swap_reloc_out (abfd, &n, &dst); coff_swap_reloc_out (abfd, &n, &dst);