From: Christopher Li <sparse@chrisli.org>
To: Martin Nagy <mnagy@redhat.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH] Print an error if typeof() lacks an argument
Date: Sun, 26 Apr 2009 23:38:51 -0700 [thread overview]
Message-ID: <70318cbf0904262338g698eb2g7265b472fb0efd46@mail.gmail.com> (raw)
In-Reply-To: <20090425130343.3df87cbb@notas>
On Sat, Apr 25, 2009 at 4:03 AM, Martin Nagy <mnagy@redhat.com> wrote:
>
> We weren't checking if the initializer isn't NULL, which caused sparse
> to segfault later on when performing lazy evaluation in classify_type().
>
> Signed-off-by: Martin Nagy <nagy.martin@gmail.com>
> ---
> parse.c | 17 +++++++++++------
> 1 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/parse.c b/parse.c
> index 9662122..18cfaef 100644
> --- a/parse.c
> +++ b/parse.c
> @@ -924,12 +924,17 @@ static struct token *typeof_specifier(struct token *token, struct decl_state *ct
> ctx->ctype.base_type = sym->ctype.base_type;
> apply_ctype(token->pos, &sym->ctype, &ctx->ctype);
> } else {
> - struct symbol *typeof_sym = alloc_symbol(token->pos, SYM_TYPEOF);
> - token = parse_expression(token->next, &typeof_sym->initializer);
> -
> - typeof_sym->endpos = token->pos;
> - ctx->ctype.base_type = typeof_sym;
> - }
> + struct expression *expr;
I think you want expr = NULL here. Otherwise if(expr) will pick up crap.
I would just add two lines after "token =
parse_expression(token->next, &typeof_sym->initializer);"
if (!type->initializer)
sparse_error(token->pos, "expected expression after the '(' token");
If there is compile error, the sparse should not continue the later
stage any way.
BTW, can you add a validation test case which will trigger the bug?
Thanks
Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-04-27 6:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-25 11:03 [PATCH] Print an error if typeof() lacks an argument Martin Nagy
2009-04-25 11:11 ` Martin Nagy
2009-04-27 6:38 ` Christopher Li [this message]
2009-04-27 9:15 ` Martin Nagy
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=70318cbf0904262338g698eb2g7265b472fb0efd46@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=linux-sparse@vger.kernel.org \
--cc=mnagy@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;
as well as URLs for NNTP newsgroup(s).