Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Tom Tromey <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] PR gdb/17210 - fix possible memory leak in read_memory_robust
Date: Tue, 28 Jun 2016 10:43:00 -0000	[thread overview]
Message-ID: <CAH=s-PMjZN9byLwAGs+yQjEhDzMJEe0RxGuT-tg89+DFxgk6ew@mail.gmail.com> (raw)
In-Reply-To: <1465490013-15336-1-git-send-email-tom@tromey.com>

On Thu, Jun 9, 2016 at 5:33 PM, Tom Tromey <tom@tromey.com> wrote:
>
>  VEC(memory_read_result_s) *
> @@ -1810,6 +1810,8 @@ read_memory_robust (struct target_ops *ops,
>  {
>    VEC(memory_read_result_s) *result = 0;
>    int unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ());
> +  struct cleanup *cleanup = make_cleanup (free_memory_read_result_vector,
> +                                         &result);
>

result is a local variable on stack, so its address is meaningless when the
exception is throw, because the stack has already been destroyed.

Probably, we can register cleanup for result once it becomes to non-NULL,
and changes in free_memory_read_result_vector are not needed.

-- 
Yao (齐尧)


  reply	other threads:[~2016-06-28 10:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 16:34 Tom Tromey
2016-06-28 10:43 ` Yao Qi [this message]
2016-06-28 14:40   ` Tom Tromey
2016-06-28 17:48   ` Pedro Alves
2016-06-29  9:27     ` Yao Qi

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='CAH=s-PMjZN9byLwAGs+yQjEhDzMJEe0RxGuT-tg89+DFxgk6ew@mail.gmail.com' \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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