Check for NULL position and NULL filename. Signed-off-by: Julia Lawall <Julia.Lawall@xxxxxxx> Signed-off-by: Frank Rowand <frank.rowand@xxxxxxxx> Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> --- v4: no change srcpos.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/srcpos.c b/srcpos.c index cb6ed0e..9dd3297 100644 --- a/srcpos.c +++ b/srcpos.c @@ -244,12 +244,20 @@ srcpos_copy(struct srcpos *pos) char * srcpos_string(struct srcpos *pos) { - const char *fname = "<no-file>"; + const char *fname; char *pos_str; - if (pos->file && pos->file->name) - fname = pos->file->name; + if (!pos) { + xasprintf(&pos_str, "<no-file>:<no-line>"); + return pos_str; + } + if (!pos->file) + fname = "<no-file>"; + else if (!pos->file->name) + fname = "<no-filename>"; + else + fname = pos->file->name; if (pos->first_line != pos->last_line) xasprintf(&pos_str, "%s:%d.%d-%d.%d", fname, -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html