Skip to content
Permalink
Browse files Browse the repository at this point in the history
util: Check for NULL string in writefile
This check was there previously, but was removed in f549b75 with
the addition of a check during parse that every rule has rspfile
if and only if it has rspfile_content. However, this fails to
consider the possibility of those variables coming from the edge
or global environment. So, re-add the check.

Fixes #67.
  • Loading branch information
michaelforney committed Apr 3, 2021
1 parent 3629b72 commit e84b6d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util.c
Expand Up @@ -258,7 +258,7 @@ writefile(const char *name, struct string *s)
return -1;
}
ret = 0;
if (fwrite(s->s, 1, s->n, f) != s->n || fflush(f) != 0) {
if (s && (fwrite(s->s, 1, s->n, f) != s->n || fflush(f) != 0)) {
warn("write %s:", name);
ret = -1;
}
Expand Down

0 comments on commit e84b6d9

Please sign in to comment.