fix invalid memory access in pclose
authorRich Felker <dalias@aerifal.cx>
Wed, 20 Jun 2012 18:47:34 +0000 (14:47 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 20 Jun 2012 18:47:34 +0000 (14:47 -0400)
src/stdio/pclose.c

index c2fe7a2..7c77796 100644 (file)
@@ -3,8 +3,9 @@
 int pclose(FILE *f)
 {
        int status;
+       pid_t pid = f->pipe_pid;
        fclose(f);
-       while (waitpid(f->pipe_pid, &status, 0) == -1)
+       while (waitpid(pid, &status, 0) == -1)
                if (errno != EINTR) return -1;
        return status;
 }