Merge pull request #4453 from lambdageek/bug-49721
[mono.git] / mono / metadata / appdomain.c
index cbfa2c3c24613e59517c70334e04187846770913..81a92adc2e1a3ceb6b36797384d078e8770b7666 100644 (file)
 #include <direct.h>
 #endif
 
-/*
- * This is the version number of the corlib-runtime interface. When
- * making changes to this interface (by changing the layout
- * of classes the runtime knows about, changing icall signature or
- * semantics etc), increment this variable. Also increment the
- * pair of this variable in mscorlib in:
- *       mcs/class/corlib/System/Environment.cs
- *
- * Changes which are already detected at runtime, like the addition
- * of icalls, do not require an increment.
- */
-#define MONO_CORLIB_VERSION 164
-
 typedef struct
 {
        int runtime_count;
@@ -1188,12 +1175,13 @@ add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht)
        if (!ht) {
                ht = g_hash_table_new (mono_aligned_addr_hash, NULL);
                destroy_ht = TRUE;
+               for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
+                       g_hash_table_insert (ht, tmp->data, tmp->data);
+               }
        }
 
        /* FIXME: handle lazy loaded assemblies */
-       for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
-               g_hash_table_insert (ht, tmp->data, tmp->data);
-       }
+
        if (!g_hash_table_lookup (ht, ass)) {
                mono_assembly_addref (ass);
                g_hash_table_insert (ht, ass, ass);
@@ -1202,11 +1190,12 @@ add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht)
        }
 
        if (ass->image->references) {
-               for (i = 0; ass->image->references [i] != NULL; i++) {
-                       if (ass->image->references [i] != REFERENCE_MISSING)
+               for (i = 0; i < ass->image->nreferences; i++) {
+                       if (ass->image->references[i] && ass->image->references [i] != REFERENCE_MISSING) {
                                if (!g_hash_table_lookup (ht, ass->image->references [i])) {
                                        add_assemblies_to_domain (domain, ass->image->references [i], ht);
                                }
+                       }
                }
        }
        if (destroy_ht)