msvcrt: dont overwrite the first 3 file descriptors

André Hentschel nerv at dawncrow.de
Fri Aug 14 12:24:49 CDT 2009


MSVCRT_fdend is initialized with "static int MSVCRT_fdend = 3; /* highest allocated fd */", but in msvcrt_init_io it might be overwritten with lpReserved2 which might be 0.
This has the effect that stdin, stdout and stderr are invalid. This patch fixes this.

---
 dlls/msvcrt/file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 6671f2f..c9dd281 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -354,7 +354,7 @@ void msvcrt_init_io(void)
     char*       wxflag_ptr;
     HANDLE*     handle_ptr;
 
-    MSVCRT_fdend = *(unsigned*)si.lpReserved2;
+    MSVCRT_fdend = max(3, *(unsigned*)si.lpReserved2);
 
     wxflag_ptr = (char*)(si.lpReserved2 + sizeof(unsigned));
     handle_ptr = (HANDLE*)(wxflag_ptr + MSVCRT_fdend * sizeof(char));
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list