cgit

commit fd069b4ca08cb46eb335a1434330b21fbaf84b9c

Author: Jason A. Donenfeld <Jason@zx2c4.com>

filter: pipe_fh should be local

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

 cgit.h | 1 -
 filter.c | 13 +++++++------


diff --git a/cgit.h b/cgit.h
index 0b88dcda0d9d4e3a1e2dd5d445d5dcd6d18d2f0d..005ae63017050f0e6d5821fd51515ca0775f4469 100644
--- a/cgit.h
+++ b/cgit.h
@@ -71,7 +71,6 @@ 	struct cgit_filter base;
 	char *cmd;
 	char **argv;
 	int old_stdout;
-	int pipe_fh[2];
 	int pid;
 };
 




diff --git a/filter.c b/filter.c
index 949c931af1f67cb48df4554d6b1d7ca87d897ce2..70f5b749989c27e8bf1e87070066614805dbf5d6 100644
--- a/filter.c
+++ b/filter.c
@@ -42,6 +42,7 @@
 static int open_exec_filter(struct cgit_filter *base, va_list ap)
 {
 	struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base;
+	int pipe_fh[2];
 	int i;
 
 	for (i = 0; i < filter->base.argument_count; i++)
@@ -49,19 +50,19 @@ 		filter->argv[i + 1] = va_arg(ap, char *);
 
 	filter->old_stdout = chk_positive(dup(STDOUT_FILENO),
 		"Unable to duplicate STDOUT");
-	chk_zero(pipe(filter->pipe_fh), "Unable to create pipe to subprocess");
+	chk_zero(pipe(pipe_fh), "Unable to create pipe to subprocess");
 	filter->pid = chk_non_negative(fork(), "Unable to create subprocess");
 	if (filter->pid == 0) {
-		close(filter->pipe_fh[1]);
-		chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO),
+		close(pipe_fh[1]);
+		chk_non_negative(dup2(pipe_fh[0], STDIN_FILENO),
 			"Unable to use pipe as STDIN");
 		execvp(filter->cmd, filter->argv);
 		die_errno("Unable to exec subprocess %s", filter->cmd);
 	}
-	close(filter->pipe_fh[0]);
-	chk_non_negative(dup2(filter->pipe_fh[1], STDOUT_FILENO),
+	close(pipe_fh[0]);
+	chk_non_negative(dup2(pipe_fh[1], STDOUT_FILENO),
 		"Unable to use pipe as STDOUT");
-	close(filter->pipe_fh[1]);
+	close(pipe_fh[1]);
 	return 0;
 }