public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Tom de Vries <tdevries@suse.de>, Joseph Myers <joseph@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org, Ian Lance Taylor <ian@airs.com>
Subject: Re: [PATCH 2/4][libbacktrace] Avoid realloc with size == 0 in backtrace_vector_release
Date: Mon, 26 Nov 2018 22:24:00 -0000	[thread overview]
Message-ID: <fbf884b4-1c6c-71b4-aa5c-8d689600ad82@redhat.com> (raw)
In-Reply-To: <20181123205117.GB1927@delia>

On 11/23/18 1:51 PM, Tom de Vries wrote:
> [ was: Re: [PATCH 1/2][libbacktrace] Handle realloc returning NULL if size ==
> 0 ]
>  
> On Thu, Nov 22, 2018 at 06:16:20PM +0000, Joseph Myers wrote:
>> On Thu, 22 Nov 2018, Tom de Vries wrote:
>>
>>> Hi,
>>>
>>> If realloc is called with size 0, realloc can return NULL.
>>
>> Note that, as of C17, realloc with size 0 is marked as an obsolescent 
>> feature (because of inconsistencies between implementations regarding 
>> whether the old object is deallocated).  So it would be advisable for code 
>> intended to be portable to avoid calling realloc with size 0 at all.
>>
> 
> Updated patch to avoid realloc with size 0.
> 
> OK for trunk?
> 
> Thanks,
> - Tom
> 
> [libbacktrace] Avoid realloc with size == 0 in backtrace_vector_release
> 
> As of C17, realloc with size 0 is marked as an obsolescent feature.
> 
> Fix this in backtrace_vector_release by using free instead.
> 
> Bootstrapped and reg-tested on x86_64.
> 
> 2018-11-22  Tom de Vries  <tdevries@suse.de>
> 
> 	* alloc.c (backtrace_vector_release): Handle vec->size == 0 using free
> 	instead of realloc.
> 	* Makefile.am (check_PROGRAMS): Add unittest.
> 	* Makefile.in: Regenerate.
> 	* unittest.c: New file.
OK.

Are any of the subsequent patches in this series still relevant?

jeff

  reply	other threads:[~2018-11-26 22:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22 12:35 [PATCH 1/2][libbacktrace] Handle realloc returning NULL if size == 0 Tom de Vries
2018-11-22 18:16 ` Joseph Myers
2018-11-23 20:51   ` [PATCH 2/4][libbacktrace] Avoid realloc with size == 0 in backtrace_vector_release Tom de Vries
2018-11-26 22:24     ` Jeff Law [this message]
2018-11-23 20:47 ` [PATCH 1/4][libbacktrace] Test check_PROGRAMS without mmap Tom de Vries
2018-11-28 12:15   ` Tom de Vries
2018-11-29 18:26   ` Ian Lance Taylor via gcc-patches
2018-11-30  9:04     ` Tom de Vries
2018-11-30 14:45       ` Ian Lance Taylor via gcc-patches

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=fbf884b4-1c6c-71b4-aa5c-8d689600ad82@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ian@airs.com \
    --cc=joseph@codesourcery.com \
    --cc=tdevries@suse.de \
    /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).