* [Fwd: Re: [patch] coffgen.c, degenerate case]
@ 2007-07-26 1:43 msnyder
2007-07-27 0:36 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: msnyder @ 2007-07-26 1:43 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 664 bytes --]
DJ Delorie writes:
> msnyder@sonic.net writes:
>> --- 1446,1456 ----
>> size = obj_raw_syment_count (abfd) * symesz;
>>
>> syms = bfd_malloc (size);
>> ! if (syms == NULL)
>> ! if (size == 0)
>> ! return TRUE;
>> ! else
>> ! return FALSE;
>>
>> if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
>> || bfd_bread (syms, size, abfd) != size)
>
> Why not test earlier, and bypass the bfd_malloc completely?
Ummm... I can think of no good reason.
> Also, please add braces around the inner if/else so that the else
> doesn't appear ambiguous.
Gotcha -- except now I don't need a nested if.
Revised patch attached.
[-- Attachment #2: coffgen3.txt --]
[-- Type: text/plain, Size: 1053 bytes --]
2007-07-25 Michael Snyder <msnyder@access-company.com>
* coffgen.c (_bfd_coff_get_external_symbols): Nothing to be done
if size == 0; return and avoid possible null pointer issues.
Index: coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.59
diff -p -r1.59 coffgen.c
*** coffgen.c 12 Jul 2007 07:16:40 -0000 1.59
--- coffgen.c 26 Jul 2007 01:27:09 -0000
*************** _bfd_coff_get_external_symbols (bfd *abf
*** 1444,1452 ****
symesz = bfd_coff_symesz (abfd);
size = obj_raw_syment_count (abfd) * symesz;
syms = bfd_malloc (size);
! if (syms == NULL && size != 0)
return FALSE;
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
--- 1449,1459 ----
symesz = bfd_coff_symesz (abfd);
size = obj_raw_syment_count (abfd) * symesz;
+ if (size == 0)
+ return TRUE;
syms = bfd_malloc (size);
! if (syms == NULL)
return FALSE;
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Fwd: Re: [patch] coffgen.c, degenerate case]
2007-07-26 1:43 [Fwd: Re: [patch] coffgen.c, degenerate case] msnyder
@ 2007-07-27 0:36 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2007-07-27 0:36 UTC (permalink / raw)
To: msnyder; +Cc: binutils
On Wed, Jul 25, 2007 at 06:32:19PM -0700, msnyder@sonic.net wrote:
> * coffgen.c (_bfd_coff_get_external_symbols): Nothing to be done
> if size == 0; return and avoid possible null pointer issues.
OK.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-27 0:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 1:43 [Fwd: Re: [patch] coffgen.c, degenerate case] msnyder
2007-07-27 0:36 ` Alan Modra
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).