mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +07:00
run_interactive(): Fix a potential file descriptor leak.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -502,7 +502,7 @@ int run_interactive(char *cmd, char *fmt, ...)
|
||||
int status, oldout = 1, olderr = 2;
|
||||
char line[LINE_SIZE];
|
||||
va_list ap;
|
||||
FILE *fp = tmpfile();
|
||||
FILE *fp;
|
||||
|
||||
if (!cmd) {
|
||||
errno = EINVAL;
|
||||
@@ -518,6 +518,7 @@ int run_interactive(char *cmd, char *fmt, ...)
|
||||
}
|
||||
|
||||
/* Redirect output from cmd to a tempfile */
|
||||
fp = tmpfile();
|
||||
if (fp && !debug) {
|
||||
oldout = dup(STDOUT_FILENO);
|
||||
olderr = dup(STDERR_FILENO);
|
||||
|
||||
Reference in New Issue
Block a user