mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +07:00
fnwrite(): call fclose() separately, found by Coverity Scan
If any of the fputs() calls fails we will not call fclose() and thus cause resource loss. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+3
-3
@@ -105,9 +105,9 @@ int fnwrite(char *value, char *fmt, ...)
|
||||
return -1;
|
||||
|
||||
/* echo(1) always adds a newline */
|
||||
if (fputs(value, fp) == EOF ||
|
||||
fputs("\n", fp) == EOF ||
|
||||
fclose(fp) == EOF)
|
||||
if (fputs(value, fp) == EOF || fputs("\n", fp) == EOF)
|
||||
rc = -1;
|
||||
if (fclose(fp) == EOF)
|
||||
rc = -1;
|
||||
else
|
||||
rc = 0;
|
||||
|
||||
Reference in New Issue
Block a user