public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] readelf: Replace xmalloc with malloc in slurp_relr_relocs
@ 2022-06-07 21:23 Marcus Nilsson
  2022-06-08  6:11 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Marcus Nilsson @ 2022-06-07 21:23 UTC (permalink / raw)
  To: binutils

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-17  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-07 21:23 [PATCH] readelf: Replace xmalloc with malloc in slurp_relr_relocs Marcus Nilsson
2022-06-08  6:11 ` Jan Beulich
2022-06-17  9:01   ` Marcus Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).