MonoError error;
MonoInternalThread *internal = mono_thread_internal_current ();
- mono_thread_set_name_internal (internal, mono_string_new (mono_domain_get (), "AOT compiler"), TRUE, FALSE, &error);
+ MonoString *str = mono_string_new_checked (mono_domain_get (), "AOT compiler", &error);
+ mono_error_assert_ok (&error);
+ mono_thread_set_name_internal (internal, str, TRUE, FALSE, &error);
mono_error_assert_ok (&error);
for (i = 0; i < methods->len; ++i)
case CMD_APPDOMAIN_CREATE_STRING: {
char *s;
MonoString *o;
+ MonoError error;
domain = decode_domainid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
return err;
s = decode_string (p, &p, end);
- o = mono_string_new (domain, s);
+ o = mono_string_new_checked (domain, s, &error);
+ if (!is_ok (&error)) {
+ DEBUG_PRINTF (1, "[dbg] Failed to allocate String object '%s': %s\n", s, mono_error_get_message (&error));
+ mono_error_cleanup (&error);
+ return ERR_INVALID_OBJECT;
+ }
buffer_add_objid (buf, (MonoObject*)o);
break;
}
debugger_thread_id = mono_native_thread_id_get ();
MonoInternalThread *internal = mono_thread_internal_current ();
- mono_thread_set_name_internal (internal, mono_string_new (mono_domain_get (), "Debugger agent"), TRUE, FALSE, &error);
+ MonoString *str = mono_string_new_checked (mono_domain_get (), "Debugger agent", &error);
+ mono_error_assert_ok (&error);
+ mono_thread_set_name_internal (internal, str, TRUE, FALSE, &error);
mono_error_assert_ok (&error);
internal->state |= ThreadState_Background;
if (args) {
main_args = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, 1, &error);
- if (main_args)
- mono_array_set (main_args, MonoString*, 0, mono_string_new (domain, args));
+ if (main_args) {
+ MonoString *str = mono_string_new_checked (domain, args, &error);
+ if (str)
+ mono_array_set (main_args, MonoString*, 0, str);
+ }
} else {
main_args = (MonoArray*)mono_array_new_checked (domain, mono_defaults.string_class, 0, &error);
}
sf->method = NULL;
s = mono_method_get_name_full (method, TRUE, FALSE, MONO_TYPE_NAME_FORMAT_REFLECTION);
- MONO_OBJECT_SETREF (sf, internal_method_name, mono_string_new (domain, s));
+ MonoString *name = mono_string_new_checked (domain, s, &error);
g_free (s);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
+ MONO_OBJECT_SETREF (sf, internal_method_name, name);
}
else {
MonoReflectionMethod *rm = mono_method_get_object_checked (domain, method, NULL, &error);
if (need_file_info) {
if (location && location->source_file) {
- MONO_OBJECT_SETREF (sf, filename, mono_string_new (domain, location->source_file));
+ MonoString *filename = mono_string_new_checked (domain, location->source_file, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
+ MONO_OBJECT_SETREF (sf, filename, filename);
sf->line = location->row;
sf->column = location->column;
} else {
if (need_file_info) {
if (location) {
- mono_gc_wbarrier_generic_store (file, (MonoObject*) mono_string_new (domain, location->source_file));
+ MonoString *filename = mono_string_new_checked (domain, location->source_file, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return FALSE;
+ }
+ mono_gc_wbarrier_generic_store (file, (MonoObject*)filename);
*line = location->row;
*column = location->column;
} else {
g_assert (ctx != NULL);
if (!obj) {
MonoException *ex = mono_get_exception_null_reference ();
- MONO_OBJECT_SETREF (ex, message, mono_string_new (domain, "Object reference not set to an instance of an object"));
+ MonoString *msg = mono_string_new_checked (domain, "Object reference not set to an instance of an object", &error);
+ mono_error_assert_ok (&error);
+ MONO_OBJECT_SETREF (ex, message, msg);
obj = (MonoObject *)ex;
}
char *from_name = mono_type_get_full_name (jit_tls->class_cast_from);
char *to_name = mono_type_get_full_name (jit_tls->class_cast_to);
char *msg = g_strdup_printf ("Unable to cast object of type '%s' to type '%s'.", from_name, to_name);
- mono_ex->message = mono_string_new (domain, msg);
+ mono_ex->message = mono_string_new_checked (domain, msg, &error);
g_free (from_name);
g_free (to_name);
+ if (!is_ok (&error)) {
+ mono_runtime_printf_err ("Error creating class cast exception message '%s'\n", msg);
+ mono_error_assert_ok (&error);
+ }
g_free (msg);
}
if (!strcmp (mono_ex->object.vtable->klass->name, "ArrayTypeMismatchException")) {
char *from_name = mono_type_get_full_name (jit_tls->class_cast_from);
char *to_name = mono_type_get_full_name (jit_tls->class_cast_to);
char *msg = g_strdup_printf ("Source array of type '%s' cannot be cast to destination array type '%s'.", from_name, to_name);
- mono_ex->message = mono_string_new (domain, msg);
+ mono_ex->message = mono_string_new_checked (domain, msg, &error);
g_free (from_name);
g_free (to_name);
+ if (!is_ok (&error)) {
+ mono_runtime_printf_err ("Error creating array type mismatch exception message '%s'\n", msg);
+ mono_error_assert_ok (&error);
+ }
g_free (msg);
}
}