On Mon, Jul 11, 2016 at 12:17:08AM +0200, Jean-Christophe Dubois wrote: > Signed-off-by: Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx> A patch like this really needs a commit message describing when the situation it's guarding against can occur. In this case when can pos->file be non-NULL, but pos->file->name == NULL. It's not exactly high priority, since srcpos_dump() has no current users AFAICT. > --- > srcpos.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/srcpos.c b/srcpos.c > index af7fb3c..927ac54 100644 > --- a/srcpos.c > +++ b/srcpos.c > @@ -252,7 +252,7 @@ void > srcpos_dump(struct srcpos *pos) > { > printf("file : \"%s\"\n", > - pos->file ? (char *) pos->file : "<no file>"); > + (pos->file && pos->file->name) ? pos->file->name : "<no file>"); > printf("first_line : %d\n", pos->first_line); > printf("first_column: %d\n", pos->first_column); > printf("last_line : %d\n", pos->last_line); > @@ -267,7 +267,7 @@ srcpos_string(struct srcpos *pos) > const char *fname = "<no-file>"; > char *pos_str; > > - if (pos) > + if (pos->file && pos->file->name) > fname = pos->file->name; > > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature