Browse Source

fix invalid memory access in pclose

Rich Felker 13 năm trước cách đây
mục cha
commit
9799560f79
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      src/stdio/pclose.c

+ 2 - 1
src/stdio/pclose.c

@@ -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;
 }