Aviod seg fault when no file

This commit is contained in:
rsc 2006-08-29 20:15:01 +00:00
parent c7c29d26b7
commit 21c4c72798

View file

@ -12,7 +12,10 @@ void
setname(File *f)
{
char buf[1024];
snprint(buf, sizeof buf, "%.*S", f->name.n, f->name.s);
if(f)
snprint(buf, sizeof buf, "%.*S", f->name.n, f->name.s);
else
buf[0] = 0;
putenv("samfile", buf);
}