Merge pull request #3749 from BrzVlad/fix-mips-fix
[mono.git] / mono / metadata / file-io.c
index a871337ee36d15cd920d5edc8997f67a7d32d350..1e0422e35fbc0f069b63b3136850af188a785384 100644 (file)
@@ -34,6 +34,7 @@
 #include <mono/metadata/marshal.h>
 #include <mono/utils/strenc.h>
 #include <utils/mono-io-portability.h>
+#include <mono/utils/w32handle.h>
 
 #undef DEBUG
 
@@ -488,8 +489,13 @@ ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
        ifh = g_new (IncrementalFind, 1);
        ifh->find_handle = find_handle;
        ifh->utf8_path = mono_string_to_utf8_checked (path, &error);
-       if (mono_error_set_pending_exception (&error))
+       if (mono_error_set_pending_exception (&error)) {
+               MONO_ENTER_GC_SAFE;
+               FindClose (find_handle);
+               MONO_EXIT_GC_SAFE;
+               g_free (ifh);
                return NULL;
+       }
        ifh->domain = mono_domain_get ();
        *handle = ifh;
 
@@ -799,10 +805,6 @@ ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
                if (options & FileOptions_Temporary)
                        attributes |= FILE_ATTRIBUTE_TEMPORARY;
                
-               /* Not sure if we should set FILE_FLAG_OVERLAPPED, how does this mix with the "Async" bool here? */
-               if (options & FileOptions_Asynchronous)
-                       attributes |= FILE_FLAG_OVERLAPPED;
-               
                if (options & FileOptions_WriteThrough)
                        attributes |= FILE_FLAG_WRITE_THROUGH;
        } else
@@ -1272,11 +1274,11 @@ mono_filesize_from_fd (int fd)
 
 #endif
 
-void _wapi_handle_dump (void);
+void mono_w32handle_dump (void);
 
 void ves_icall_System_IO_MonoIO_DumpHandles (void)
 {
 #ifndef HOST_WIN32
-       _wapi_handle_dump ();
+       mono_w32handle_dump ();
 #endif
 }