mirror of
https://github.com/troglobit/finit.git
synced 2026-10-29 12:40:44 +00: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:
1 parent
34875f57a5
commit
12eaa3073a
1 file changed
+3
-3
+3
-3
@@ -105,9 +105,9 @@ int fnwrite(char *value, char *fmt, ...)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* echo(1) always adds a newline */
|
/* echo(1) always adds a newline */
|
||||||
if (fputs(value, fp) == EOF ||
|
if (fputs(value, fp) == EOF || fputs("\n", fp) == EOF)
|
||||||
fputs("\n", fp) == EOF ||
|
rc = -1;
|
||||||
fclose(fp) == EOF)
|
if (fclose(fp) == EOF)
|
||||||
rc = -1;
|
rc = -1;
|
||||||
else
|
else
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user