public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: msnyder@sonic.net
To: binutils@sourceware.org
Subject: [patch] coffgen.c, degenerate case
Date: Wed, 25 Jul 2007 23:45:00 -0000	[thread overview]
Message-ID: <9013.12.7.175.2.1185406480.squirrel@webmail.sonic.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 127 bytes --]

If size == 0 and bfd_malloc returns NULL, just return.
No actual work to do anyway, and avoids passing null ptr to bfd_bread.


[-- Attachment #2: coffgen1.txt --]
[-- Type: text/plain, Size: 1088 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	25 Jul 2007 23:30:25 -0000
*************** _bfd_coff_get_external_symbols (bfd *abf
*** 1446,1453 ****
    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
        || bfd_bread (syms, size, abfd) != size)
--- 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)

             reply	other threads:[~2007-07-25 23:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-25 23:45 msnyder [this message]
     [not found] ` <xnfy3c557p.fsf@greed.delorie.com>
     [not found]   ` <22417.12.7.175.2.1185413421.squirrel@webmail.sonic.net>
2007-07-26  1:59     ` DJ Delorie
2007-07-26  2:19       ` msnyder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9013.12.7.175.2.1185406480.squirrel@webmail.sonic.net \
    --to=msnyder@sonic.net \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).