Index: dplobby.c
===================================================================
RCS file: /home/wine/wine/dlls/dplayx/dplobby.c,v
retrieving revision 1.39
diff -u -r1.39 dplobby.c
--- dplobby.c	26 Jan 2005 21:09:05 -0000	1.39
+++ dplobby.c	8 Mar 2005 20:54:46 -0000
@@ -1156,22 +1156,18 @@
                                    LPHANDLE lphRead )
 {
   /* These are the handles for the created process */
-  HANDLE hAppStart, hAppDeath, hAppRead, hTemp;
+  HANDLE hAppStart = INVALID_HANDLE_VALUE;
+  HANDLE hAppDeath = INVALID_HANDLE_VALUE;
+  HANDLE hAppRead  = INVALID_HANDLE_VALUE;
   SECURITY_ATTRIBUTES s_attrib;
 
   s_attrib.nLength              = sizeof( s_attrib );
   s_attrib.lpSecurityDescriptor = NULL;
   s_attrib.bInheritHandle       = TRUE;
 
-  /* FIXME: Is there a handle leak here? */
-  hTemp = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
-  *lphStart = ConvertToGlobalHandle( hTemp );
-
-  hTemp = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
-  *lphDeath = ConvertToGlobalHandle( hTemp );
-
-  hTemp = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
-  *lphRead  = ConvertToGlobalHandle( hTemp );
+  *lphStart = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
+  *lphDeath = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
+  *lphRead  = CreateEventW( &s_attrib, TRUE, FALSE, NULL );
 
   if( ( !DuplicateHandle( GetCurrentProcess(), *lphStart,
                           hDestProcess, &hAppStart,
@@ -1185,6 +1181,13 @@
     )
   {
     /* FIXME: Handle leak... */
+    if (INVALID_HANDLE_VALUE != *lphStart) { CloseHandle(*lphStart); *lphStart = INVALID_HANDLE_VALUE; }
+    if (INVALID_HANDLE_VALUE != *lphDeath) { CloseHandle(*lphDeath); *lphDeath = INVALID_HANDLE_VALUE; }
+    if (INVALID_HANDLE_VALUE != *lphRead)  { CloseHandle(*lphRead);  *lphRead  = INVALID_HANDLE_VALUE; }
+    if (INVALID_HANDLE_VALUE != hAppStart) CloseHandle(hAppStart);
+    if (INVALID_HANDLE_VALUE != hAppDeath) CloseHandle(hAppDeath);
+    if (INVALID_HANDLE_VALUE != hAppRead)  CloseHandle(hAppRead);
+
     ERR( "Unable to dup handles\n" );
     return FALSE;
   }
