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

* Re: [PATCH] readelf: Replace xmalloc with malloc in slurp_relr_relocs
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2022-06-08  6:11 UTC (permalink / raw)
  To: Marcus Nilsson; +Cc: binutils

On 07.06.2022 23:23, Marcus Nilsson via Binutils wrote:
> 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.

OK.

Jan


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

* Re: [PATCH] readelf: Replace xmalloc with malloc in slurp_relr_relocs
  2022-06-08  6:11 ` Jan Beulich
@ 2022-06-17  9:01   ` Marcus Nilsson
  0 siblings, 0 replies; 3+ messages in thread
From: Marcus Nilsson @ 2022-06-17  9:01 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

Thank you for you reply. Since I don't have push permissions, feel free to
commit this one if no one disapproves.

Thanks,
Marcus Nilsson

On Wed, Jun 8, 2022 at 8:11 AM Jan Beulich <jbeulich@suse.com> wrote:

> On 07.06.2022 23:23, Marcus Nilsson via Binutils wrote:
> > 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.
>
> OK.
>
> Jan
>
>

-- 
Marcus Nilsson
-
tel: +46(0)704911844
mail: marcus@landmarknilsson.se
github: github.com/metmo
linkedin: linkedin.com/in/landmarknilsson

^ 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).