Don't try to fflush(export_fp) or ferror(export_fp) if export_fp

is NULL, which can happen on the error path.
This commit is contained in:
Todd C. Miller
2016-05-16 14:16:08 -06:00
parent a2e541aef8
commit eb4510597b

View File

@@ -1062,10 +1062,12 @@ export_sudoers(const char *sudoers_path, const char *export_path,
fputs("\n}\n", export_fp); fputs("\n}\n", export_fp);
done: done:
if (export_fp != NULL) {
(void)fflush(export_fp); (void)fflush(export_fp);
if (ferror(export_fp)) if (ferror(export_fp))
rval = false; rval = false;
if (export_fp != stdout && export_fp != NULL) if (export_fp != stdout)
fclose(export_fp); fclose(export_fp);
}
debug_return_bool(rval); debug_return_bool(rval);
} }