Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: msnyder@sonic.net
To: msnyder@sonic.net, gdb-patches@sourceware.org
Subject: Re: [OB] cli/cli-script.c, null ptr guard
Date: Tue, 03 Jul 2007 01:13:00 -0000	[thread overview]
Message-ID: <7995.12.7.175.2.1183425206.squirrel@webmail.sonic.net> (raw)
In-Reply-To: <20070701155543.GF10872@caradoc.them.org>

> On Thu, Jun 28, 2007 at 04:04:29PM -0700, Michael Snyder wrote:
>> > On Thu, Jun 28, 2007 at 03:17:18PM -0700, msnyder@sonic.net wrote:
>> >> > No, I don't think this is obvious.  What does it mean to have a
>> null
>> >> > string here and how can it happen?  I'm pretty sure it can't, and
>> the
>> >> > if check is just clutter.
>> >>
>> >> The reasoning is that, since we checked it for NULL in the
>> >> first statement of the function, we must believe that the
>> >> possibility exists for it to be NULL.
>> >
>> > Right.  So, is it a sensible check?  Or should it be removed, or
>> > should the condition for the error be simplified?
>>
>> Well, it either makes sense to check it for null, or it doesn't.
>> If the new test is redundant, so is the old one.  Whoever wrote
>> it in the first place seemed to think it was worth checking.
>>
>> This is called from a number of places, but they are all local to the
>> module.
>>
>> Ultimately the argument comes from the command parser.
>> It's one of those typical (char *args, int from_tty) things.
>
> There's four calls to build_command_line.  Three are passed a freshly
> incremented pointer, so it can never be NULL.  That's
> if/while/commands.  The other one came from get_command_line.  Those
> can be NULL - well, I'm not sure, but I think they can.  They're
> always if/while.
>
> So how about adding gdb_assert (args != NULL) after the error call,
> like below?  If you follow where the result of this function goes,
> if we actually set cmd->line = NULL we will crash.

Yes, OK, will commit as shown.



  reply	other threads:[~2007-07-03  1:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-28 21:51 msnyder
2007-06-28 22:15 ` Daniel Jacobowitz
2007-06-28 22:27   ` msnyder
2007-06-28 22:48     ` Daniel Jacobowitz
2007-06-28 23:06       ` msnyder
2007-07-01 15:56         ` Daniel Jacobowitz
2007-07-03  1:13           ` msnyder [this message]
2007-07-03  1:14             ` msnyder
2007-07-03  1:23               ` Daniel Jacobowitz

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=7995.12.7.175.2.1183425206.squirrel@webmail.sonic.net \
    --to=msnyder@sonic.net \
    --cc=gdb-patches@sourceware.org \
    /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