From: Stephen Warren <swarren@wwwdotorg.org>
To: Markus Mayer <mmayer@broadcom.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix segfault in dtc when empty input file is given.
Date: Tue, 25 Sep 2012 09:44:31 -0600 [thread overview]
Message-ID: <5061D15F.6070408@wwwdotorg.org> (raw)
In-Reply-To: <20120914222304.GA2698@mmayer.net>
On 09/14/2012 04:23 PM, Markus Mayer wrote:
> Prior to this change, an empty input file would cause a segfault, because
> yylloc had never been initialized. There was never any characters for the
> lexer to match, so YY_USER_ACTION was never executed before the parse error
> was detected.
>
> When the parser printed the error message, it tried to include the name of
> the file, but the structure holding the file name (yylloc.file, referenced
> as pos->file) had never been initialized.
> diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c
> struct boot_info *dt_from_source(const char *fname)
> {
> + extern YYLTYPE yylloc;
> +
> the_boot_info = NULL;
> treesource_error = 0;
>
> srcfile_push(fname);
> yyin = current_srcfile->f;
> + /* Initialize yylloc->file to avoid segfault on empty input */
> + srcpos_update(&yylloc, NULL, 0);
Wouldn't srcpos_update(&yyloc, fname, 0); be even more informative?
prev parent reply other threads:[~2012-09-25 15:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 22:23 [PATCH] Fix segfault in dtc when empty input file is given Markus Mayer
2012-09-25 15:44 ` Stephen Warren [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=5061D15F.6070408@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmayer@broadcom.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.