public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@linaro.org>
To: Michael Snyder <msnyder@vmware.com>
Cc: "binutils\@sourceware.org" <binutils@sourceware.org>
Subject: Re: [RFA] wrstabs.c (stab_start_struct_type): Close memory leak.
Date: Mon, 14 Mar 2011 12:27:00 -0000	[thread overview]
Message-ID: <g4pqpt3n1y.fsf@linaro.org> (raw)
In-Reply-To: <4D76800E.2040107@vmware.com> (Michael Snyder's message of "Tue,	08 Mar 2011 11:14:22 -0800")

Michael Snyder <msnyder@vmware.com> writes:
> OK?
>
> 2011-03-08  Michael Snyder  <msnyder@vmware.com>
>
> 	* wrstabs.c (stab_start_struct_type): Close memory leak.
>
> Index: wrstabs.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/wrstabs.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 wrstabs.c
> --- wrstabs.c	28 Feb 2011 18:32:51 -0000	1.20
> +++ wrstabs.c	8 Mar 2011 19:10:07 -0000
> @@ -1337,11 +1337,15 @@ stab_start_struct_type (void *p, const c
>  	   size);
>  
>    if (! stab_push_string (info, buf, tindex, definition, size))
> -    return FALSE;
> +    {
> +      free (buf);
> +      return FALSE;
> +    }
>  
>    info->type_stack->fields = (char *) xmalloc (1);
>    info->type_stack->fields[0] = '\0';
>  
> +  free (buf);
>    return TRUE;
>  }
>  

Better to replace:

  char *buf;

  buf = (char *) xmalloc (40);

with

  char buf[40];

That change is preapproved, if it works.

Richard

      reply	other threads:[~2011-03-14 12:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-08 19:14 Michael Snyder
2011-03-14 12:27 ` Richard Sandiford [this message]

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=g4pqpt3n1y.fsf@linaro.org \
    --to=richard.sandiford@linaro.org \
    --cc=binutils@sourceware.org \
    --cc=msnyder@vmware.com \
    /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).