]> err.no Git - moreutils/commitdiff
fix cleanup on error
authorJoey Hess <joey@kitenet.net>
Tue, 22 May 2012 17:39:24 +0000 (13:39 -0400)
committerJoey Hess <joey@kitenet.net>
Tue, 22 May 2012 17:39:24 +0000 (13:39 -0400)
pee.c

diff --git a/pee.c b/pee.c
index cd3ff200de1114e67f54623bd023520d07364e56..a8565c0245914cfa8bc8fb2c46dcb83c7f1dd8ab 100644 (file)
--- a/pee.c
+++ b/pee.c
@@ -40,7 +40,7 @@ main(int argc, char **argv) {
                pipes[i - 1] = popen(argv[i], "w");
                if (!pipes[i - 1]) {
                        fprintf(stderr, "Can not open pipe to '%s\'\n", argv[i]);
-                       close_pipes(pipes, i);
+                       close_pipes(pipes, argc);
 
                        exit(EXIT_FAILURE);
                }
@@ -52,7 +52,7 @@ main(int argc, char **argv) {
                for(i = 0; i < argc; i++) {
                        if (fwrite(buf, sizeof(char), r, pipes[i]) != r) {
                                fprintf(stderr, "Write error to `%s\'\n", argv[i + 1]);
-                               close_pipes(pipes, i);
+                               close_pipes(pipes, argc);
                                exit(EXIT_FAILURE);
                        }
                }