X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Floader.c;h=56992b3612738bd5ea800a0a50edc2817068c202;hb=56ad8f4e5dfb8198e4671f631a3103b1e8b83dd3;hp=56630da1eddbdf44b210c32f3670351a49b502e7;hpb=a341404ecdd3b5ca2ed0ab1e9a5bcb9b5ccd2566;p=mono.git diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index 56630da1edd..56992b36127 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -17,6 +17,7 @@ * TODO: * This should keep track of the assembly versions that we are loading. * + * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include #include @@ -563,7 +564,9 @@ mono_field_from_token_checked (MonoImage *image, guint32 token, MonoClass **retk MonoClass *handle_class; *retklass = NULL; - result = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context); + MonoError inner_error; + result = (MonoClassField *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context, &inner_error); + mono_error_cleanup (&inner_error); // This checks the memberref type as well if (!result || handle_class != mono_defaults.fieldhandle_class) { mono_error_set_bad_image (error, image, "Bad field token 0x%08x", token); @@ -874,27 +877,31 @@ mono_inflate_generic_signature (MonoMethodSignature *sig, MonoGenericContext *co static MonoMethodHeader* inflate_generic_header (MonoMethodHeader *header, MonoGenericContext *context, MonoError *error) { - MonoMethodHeader *res; - int i; - res = (MonoMethodHeader *)g_malloc0 (MONO_SIZEOF_METHOD_HEADER + sizeof (gpointer) * header->num_locals); + size_t locals_size = sizeof (gpointer) * header->num_locals; + size_t clauses_size = header->num_clauses * sizeof (MonoExceptionClause); + size_t header_size = MONO_SIZEOF_METHOD_HEADER + locals_size + clauses_size; + MonoMethodHeader *res = (MonoMethodHeader *)g_malloc0 (header_size); + res->num_locals = header->num_locals; + res->clauses = (MonoExceptionClause *) &res->locals [res->num_locals] ; + memcpy (res->clauses, header->clauses, clauses_size); + res->code = header->code; res->code_size = header->code_size; res->max_stack = header->max_stack; res->num_clauses = header->num_clauses; res->init_locals = header->init_locals; - res->num_locals = header->num_locals; - res->clauses = header->clauses; + + res->is_transient = TRUE; mono_error_init (error); - for (i = 0; i < header->num_locals; ++i) { + for (int i = 0; i < header->num_locals; ++i) { res->locals [i] = mono_class_inflate_generic_type_checked (header->locals [i], context, error); if (!is_ok (error)) goto fail; } if (res->num_clauses) { - res->clauses = (MonoExceptionClause *)g_memdup (header->clauses, sizeof (MonoExceptionClause) * res->num_clauses); - for (i = 0; i < header->num_clauses; ++i) { + for (int i = 0; i < header->num_clauses; ++i) { MonoExceptionClause *clause = &res->clauses [i]; if (clause->flags != MONO_EXCEPTION_CLAUSE_NONE) continue; @@ -1873,7 +1880,8 @@ mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass, if (image_is_dynamic (image)) { MonoClass *handle_class; - result = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context); + result = (MonoMethod *)mono_lookup_dynamic_token_class (image, token, TRUE, &handle_class, context, error); + mono_error_assert_ok (error); mono_loader_assert_no_error (); // This checks the memberref type as well @@ -2827,20 +2835,7 @@ mono_method_get_header_checked (MonoMethod *method, MonoError *error) return NULL; } - mono_image_lock (img); - - if (imethod->header) { - mono_metadata_free_mh (iheader); - mono_image_unlock (img); - return imethod->header; - } - - mono_memory_barrier (); - imethod->header = iheader; - - mono_image_unlock (img); - - return imethod->header; + return iheader; } if (method->wrapper_type != MONO_WRAPPER_NONE || method->sre_method) {