Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Pedro Alves <palves@redhat.com>, Alan Modra <amodra@gmail.com>,
	binutils@sourceware.org, gdb-patches@sourceware.org
Subject: Re: PR25993, read of freed memory
Date: Tue, 19 May 2020 15:38:57 -0400	[thread overview]
Message-ID: <493cca76-1e70-57fb-92ea-1ce86d82b251@simark.ca> (raw)
In-Reply-To: <5dd5a430-dff4-fd16-4cd1-126171ee6507@redhat.com>

On 2020-05-19 3:37 p.m., Pedro Alves via Gdb-patches wrote:
> On 5/19/20 2:27 PM, Simon Marchi wrote:
>> It now doesn't really make sense for symbol_file_add_from_memory to accept a malloc-ed
>> string (the point was that before we gave ownership of that malloc-ed string to bfd).
>>
>> Can you please change `char *name` to be `gdb::optional<std::string>`?
>>
>> The caller that passes a name should use string_printf to build the string, as mentioned
>> above.  The caller that does not pass a name can pass `{}`, to pass an empty optional.
> 
> Wouldn't 'const char * or NULL' work?  Seems way simpler to me.
> 
>>
>> The `if (name == NULL)` would become something like:
>>
>>   if (!name.has_value ())
>>     name.emplace ("shared object read from target memory");
>>
> 
> This would just be
> 
>   if (name == NULL)
>     name = "shared object read from target memory";

Ah yes that's better.  Though the caller should still be changed to use string_printf and
str.c_str ().

Simon



  reply	other threads:[~2020-05-19 19:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  4:32 Alan Modra
2020-05-19 13:27 ` Simon Marchi
2020-05-19 17:25   ` Christian Biesinger
2020-05-19 17:26     ` Simon Marchi
2020-05-19 18:58       ` Christian Biesinger
2020-05-19 19:37   ` Pedro Alves
2020-05-19 19:38     ` Simon Marchi [this message]
2020-05-19 23:40   ` Alan Modra
2020-05-20  0:19     ` Simon Marchi
2020-05-20  1:51       ` Alan Modra

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=493cca76-1e70-57fb-92ea-1ce86d82b251@simark.ca \
    --to=simark@simark.ca \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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