lkml.org 
[lkml]   [2012]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Fix segfault in dtc when empty input file is given.
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?



\
 
 \ /
  Last update: 2012-09-25 18:21    [W:0.097 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site