Fri Aug 3 13:13:39 CEST 2007 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Fri, 3 Aug 2007 10:56:48 +0000 (10:56 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Fri, 3 Aug 2007 10:56:48 +0000 (10:56 -0000)
* file-io.c, appdomain.c: memory leak fixes.

svn path=/trunk/mono/; revision=83394

mono/metadata/ChangeLog
mono/metadata/appdomain.c
mono/metadata/file-io.c

index 0c0f84b61abc071b347d9c023406d913519bf7ba..12ebac584eb9e036a0a9598103c635a411a24072 100644 (file)
@@ -1,3 +1,8 @@
+
+Fri Aug 3 13:13:39 CEST 2007 Paolo Molaro <lupus@ximian.com>
+
+       * file-io.c, appdomain.c: memory leak fixes.
+
 2007-08-02  Dick Porter  <dick@ximian.com>
 
        * socket-io.c
index b958fda230ef0902ed775e1b3eeee4e1350976b9..384b5e86942257be8f53473d3fa44ac563792a5b 100644 (file)
@@ -858,19 +858,20 @@ get_shadow_assembly_location (const char *filename)
        char name_hash [9];
        char path_hash [30];
        char *bname = g_path_get_basename (filename);
+       char *dirname = g_path_get_dirname (filename);
+       char *location, *dyn_base;
        MonoDomain *domain = mono_domain_get ();
        
        hash = get_cstring_hash (bname);
-       hash2 = get_cstring_hash (g_path_get_dirname (filename));
+       hash2 = get_cstring_hash (dirname);
        g_snprintf (name_hash, sizeof (name_hash), "%08x", hash);
        g_snprintf (path_hash, sizeof (path_hash), "%08x_%08x_%08x", hash ^ hash2, hash2, domain->shadow_serial);
-       return g_build_filename (mono_string_to_utf8 (domain->setup->dynamic_base), 
-                                "assembly", 
-                                "shadow", 
-                                name_hash,
-                                path_hash,
-                                bname, 
-                                NULL);
+       dyn_base = mono_string_to_utf8 (domain->setup->dynamic_base);
+       location = g_build_filename (dyn_base, "assembly", "shadow", name_hash, path_hash, bname, NULL);
+       g_free (dyn_base);
+       g_free (bname);
+       g_free (dirname);
+       return location;
 }
 
 static gboolean
index 1dd8c8dd5b008910c07893c73b9c219897c48b42..41619af4de48b73d58c26416338fd2f770d5ea35 100644 (file)
@@ -301,17 +301,17 @@ ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
 
        if (FindClose (find_handle) == FALSE) {
                *error = GetLastError ();
-               g_ptr_array_free (names, TRUE);
-               g_free (utf8_path);
-               return(NULL);
+               result = NULL;
+       } else {
+               result = mono_array_new (domain, mono_defaults.string_class, names->len);
+               for (i = 0; i < names->len; i++) {
+                       mono_array_setref (result, i, mono_string_new (domain, g_ptr_array_index (names, i)));
+               }
        }
 
-       result = mono_array_new (domain, mono_defaults.string_class,
-                                names->len);
        for (i = 0; i < names->len; i++) {
-               mono_array_setref (result, i, mono_string_new (domain, g_ptr_array_index (names, i)));
+               g_free (g_ptr_array_index (names, i));
        }
-
        g_ptr_array_free (names, TRUE);
        g_free (utf8_path);