Author: cwittich Date: Fri Oct 16 22:57:00 2009 New Revision: 43520
URL: http://svn.reactos.org/svn/reactos?rev=43520&view=rev Log: -sync msvcrt_init_io to wine 1.1.31 fixes 12 msvcrt file winetests
Modified: trunk/reactos/lib/sdk/crt/stdio/file.c
Modified: trunk/reactos/lib/sdk/crt/stdio/file.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/file.c?re... ============================================================================== --- trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] Fri Oct 16 22:57:00 2009 @@ -306,18 +306,19 @@ InitializeCriticalSection(&FILE_cs); FILE_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FILE_cs"); GetStartupInfoA(&si); - if (si.cbReserved2 != 0 && si.lpReserved2 != NULL) - { - char* wxflag_ptr; + if (si.cbReserved2 >= sizeof(unsigned int) && si.lpReserved2 != NULL) + { + BYTE* wxflag_ptr; HANDLE* handle_ptr; - - fdend = *(unsigned*)si.lpReserved2; - - wxflag_ptr = (char*)(si.lpReserved2 + sizeof(unsigned)); - handle_ptr = (HANDLE*)(wxflag_ptr + fdend * sizeof(char)); - - fdend = min(fdend, sizeof(fdesc) / sizeof(fdesc[0])); - for (i = 0; i < fdend; i++) + unsigned int count; + + count = *(unsigned*)si.lpReserved2; + wxflag_ptr = si.lpReserved2 + sizeof(unsigned); + handle_ptr = (HANDLE*)(wxflag_ptr + count); + + count = min(count, (si.cbReserved2 - sizeof(unsigned)) / (sizeof(HANDLE) + 1)); + count = min(count, sizeof(fdesc) / sizeof(fdesc[0])); + for (i = 0; i < count; i++) { if ((*wxflag_ptr & WX_OPEN) && *handle_ptr != INVALID_HANDLE_VALUE) { @@ -331,6 +332,7 @@ } wxflag_ptr++; handle_ptr++; } + fdend = max( 3, count ); for (fdstart = 3; fdstart < fdend; fdstart++) if (fdesc[fdstart].handle == INVALID_HANDLE_VALUE) break; }