[interpreter] special casing for string objects
authorBernhard Urban <bernhard.urban@xamarin.com>
Thu, 9 Feb 2017 19:42:18 +0000 (20:42 +0100)
committerBernhard Urban <bernhard.urban@xamarin.com>
Thu, 16 Feb 2017 22:09:38 +0000 (23:09 +0100)
mono/mini/interpreter/interp.c

index 26e7de88809993f771f1a2cbe71b541468bed12b..6c3ec2fcd4e06700356b02226773fcbd98a6d03c 100644 (file)
@@ -1791,7 +1791,9 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context)
                        if (csignature->hasthis)
                                --sp;
                        child_frame.stack_args = sp;
-                       if (csignature->hasthis && mono_object_is_transparent_proxy (sp->data.p)) {
+
+                       /* `this' can be NULL for string:.ctor */
+                       if (csignature->hasthis && sp->data.p && mono_object_is_transparent_proxy (sp->data.p)) {
                                child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        } else if (child_frame.runtime_method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
@@ -1876,7 +1878,9 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context)
                        if (child_frame.runtime_method->hasthis)
                                --sp;
                        child_frame.stack_args = sp;
-                       if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype && mono_object_is_transparent_proxy (sp->data.p)) {
+
+                       /* `this' can be NULL for string:.ctor */
+                       if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype && sp->data.p && mono_object_is_transparent_proxy (sp->data.p)) {
                                child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        }
@@ -2775,6 +2779,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context)
                                                mono_thread_interruption_checkpoint ();
                                        sp->data.p = o;
                                } else {
+                                       sp->data.p = NULL;
                                        child_frame.retval = &retval;
                                }
                        }