Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <lgustavo@codesourcery.com>
To: Luis Machado <lgustavo@codesourcery.com>,
	Pedro Alves <palves@redhat.com>,	<gdb-patches@sourceware.org>
Subject: Re: [PATCH] Fix potential NULL pointer dereference
Date: Mon, 24 Oct 2016 22:53:00 -0000	[thread overview]
Message-ID: <bfec44b5-8cb6-2a87-f5b2-b09f053620c1@codesourcery.com> (raw)
In-Reply-To: <120e608e-56bf-5664-4cfa-7c8921ccb6ff@codesourcery.com>

On 10/24/2016 05:39 PM, Luis Machado wrote:
> On 10/24/2016 05:26 PM, Pedro Alves wrote:
>> On 10/24/2016 10:52 PM, Luis Machado wrote:
>>
>>> diff --git a/gdb/exec.c b/gdb/exec.c
>>> index 67ecc63..5eeac44 100644
>>> --- a/gdb/exec.c
>>> +++ b/gdb/exec.c
>>> @@ -221,13 +221,20 @@ exec_file_locate_attach (int pid, int
>>> defer_bp_reset, int from_tty)
>>>      }
>>>    CATCH (err, RETURN_MASK_ERROR)
>>>      {
>>> +      const char *msg;
>>> +
>>>        if (err.message != NULL)
>>> -    warning ("%s", err.message);
>>> +    {
>>> +      warning ("%s", err.message);
>>> +      msg = err.message;
>>> +    }
>>> +      else
>>> +    msg = "";
>>>
>>
>> This is overcomplicating a bit, IMO.
>>
>>>        prev_err = err;
>>>
>>>        /* Save message so it doesn't get trashed by the catch below.  */
>>> -      prev_err.message = xstrdup (err.message);
>>> +      prev_err.message = xstrdup (msg);
>>
>>
>> I think this one liner:
>>
>>  +      if (err.message != NULL)
>>           prev_err.message = xstrdup (err.message);
>>
>> would have the same effect, since exception_print_same
>> handles NULL ex.message?
>>
>> Thanks,
>> Pedro Alves
>>
>
> Fine by me. I'll push that change then.
>

Pushed as b5e1db87897cabfd9beb8b1bd49f7d965c0f2607 now.

Thanks.


      reply	other threads:[~2016-10-24 22:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 21:52 Luis Machado
2016-10-24 22:26 ` Pedro Alves
2016-10-24 22:39   ` Luis Machado
2016-10-24 22:53     ` Luis Machado [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=bfec44b5-8cb6-2a87-f5b2-b09f053620c1@codesourcery.com \
    --to=lgustavo@codesourcery.com \
    --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