[MSVCRT] Don't Duplicate Handles in _get_osfhandle

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Thu Feb 9 12:40:08 CST 2006


Changelog:
	wine/dlls/msvcrt/file.c: _get_osfhandle
	Don't duplicate handles, otherwise they leak

This let's the Ethernut (www.ethernut.de) build process complete (only wine
as win95/98). Otherwise build aborted when moving a file was denied by the
server due to a sharing violation casued bye a dangling osf_handle.

With wine as NT or newer. the used cygwin tools need the unimplemented (but
also depreciated) level 3 of NetUserGetInfo.

-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/msvcrt/file.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/file.c,v
retrieving revision 1.94
diff -u -w -r1.94 file.c
--- wine/dlls/msvcrt/file.c	24 Jan 2006 12:51:46 -0000	1.94
+++ wine/dlls/msvcrt/file.c	9 Feb 2006 17:59:10 -0000
@@ -1205,25 +1205,7 @@
  */
 long _get_osfhandle(int fd)
 {
-  HANDLE hand = msvcrt_fdtoh(fd);
-  HANDLE newhand = hand;
-  TRACE(":fd (%d) handle (%p)\n",fd,hand);
-
-  if (hand != INVALID_HANDLE_VALUE)
-  {
-    /* FIXME: I'm not convinced that I should be copying the
-     * handle here - it may be leaked if the app doesn't
-     * close it (and the API docs don't say that it should)
-     * Not duplicating it means that it can't be inherited
-     * and so lcc's wedit doesn't cope when it passes it to
-     * child processes. I've an idea that it should either
-     * be copied by CreateProcess, or marked as inheritable
-     * when initialised, or maybe both? JG 21-9-00.
-     */
-    DuplicateHandle(GetCurrentProcess(),hand,GetCurrentProcess(),
-		    &newhand,0,TRUE,DUPLICATE_SAME_ACCESS);
-  }
-  return (long)newhand;
+  return (long) msvcrt_fdtoh(fd);
 }
 
 /*********************************************************************
@@ -1264,6 +1246,7 @@
     id = tempNum;
   }
   pattern++;
+  *pattern =letter++;
   do
   {
     if (GetFileAttributesA(retVal) == INVALID_FILE_ATTRIBUTES &&



More information about the wine-patches mailing list