[PATCH] readelf: Replace xmalloc with malloc in slurp_relr_relocs

Marcus Nilsson brainbomb@gmail.com
Tue Jun 7 21:23:43 GMT 2022


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:
	* readelf.c: (slurp_relr_relocs) Use malloc instead of xmalloc
        when allocating space for relocations.
---
 binutils/readelf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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.34.1



More information about the Binutils mailing list