From 4491a7c1aa356887a783c451a5e6cc708112b483 Mon Sep 17 00:00:00 2001 From: Marcus Nilsson Date: Wed, 22 Jun 2022 10:36:03 +0200 Subject: [PATCH] readelf: replace xmalloc with malloc in slurp_relr_relocs Using xmalloc makes the null check redundant since failing allocation will exit the program. Instead use malloc and let the error be conveyed up the call chain. --- binutils/ChangeLog | 5 +++++ binutils/readelf.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 888d453321b..8ff4e059bf9 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2022-06-22 Marcus Nilsson + + * readelf.c: (slurp_relr_relocs) Use malloc instead of xmalloc + when allocating space for relocations. + 2022-06-21 Kumar N, Bhuvanendra via Binutils * dwarf.h (struct debug_info): Add rnglists_base field. diff --git a/binutils/readelf.c b/binutils/readelf.c index 4c0a2a34767..fe0d27decc3 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -1401,7 +1401,7 @@ slurp_relr_relocs (Filedata * filedata, size++; } - *relrsp = (bfd_vma *) xmalloc (size * sizeof (bfd_vma)); + *relrsp = (bfd_vma *) malloc (size * sizeof (bfd_vma)); if (*relrsp == NULL) { free (relrs); -- 2.30.2