From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PUSHED] gdb/python: Avoid use after free in py-tui.c
Date: Fri, 5 Jun 2020 21:14:18 +0100 [thread overview]
Message-ID: <20200605201418.GE3522@embecosm.com> (raw)
In-Reply-To: <87v9k5gy07.fsf@tromey.com>
* Tom Tromey <tom@tromey.com> [2020-06-05 12:37:12 -0600]:
> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
>
> Andrew> When setting the window title of a tui frame we do this:
> Andrew> gdb::unique_xmalloc_ptr<char> value
> Andrew> = python_string_to_host_string (<python-object>);
> Andrew> ...
> Andrew> win-> window->title = value.get ();
>
> Andrew> The problem here is that 'get ()' only borrows the pointer from value,
> Andrew> when value goes out of scope the pointer will be freed. As a result,
> Andrew> the tui frame will be left with a pointer to undefined memory
> Andrew> contents.
>
> This does not make sense to me, because tui_win_info::title is a
> std::string.
>
> Andrew> Instead we should be using 'value.release ()' to take ownership of the
> Andrew> pointer from value.
>
> I suspect this introduces a memory leak instead.
My apologies. I have reverted the commit.
Sorry for the noise.
Thanks,
Andrew
prev parent reply other threads:[~2020-06-05 20:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-05 18:23 Andrew Burgess
2020-06-05 18:26 ` Christian Biesinger
2020-06-05 18:37 ` Tom Tromey
2020-06-05 20:14 ` Andrew Burgess [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=20200605201418.GE3522@embecosm.com \
--to=andrew.burgess@embecosm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).