Messages in this thread | | | Date | Tue, 25 Sep 2012 09:44:31 -0600 | From | Stephen Warren <> | Subject | Re: [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?
| |