Skip to content

Commit

Permalink
[runtime] Don't discard string conversion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkyte committed Mar 29, 2017
1 parent 2bf7d1b commit dcdfb3c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 2 additions & 0 deletions mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -7094,6 +7094,8 @@ ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
mcpath = mono_string_new (mono_domain_get (), path);
g_free (path);

g_assert (mcpath);

return mcpath;
}

Expand Down
35 changes: 18 additions & 17 deletions mono/metadata/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -6248,24 +6248,25 @@ mono_string_new_checked (MonoDomain *domain, const char *text, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;

GError *eg_error = NULL;
MonoString *o = NULL;
guint16 *ut;
glong items_written;
int l;

error_init (error);

l = strlen (text);

ut = g_utf8_to_utf16 (text, l, NULL, &items_written, &eg_error);

if (!eg_error)
o = mono_string_new_utf16_checked (domain, ut, items_written, error);
else
g_error_free (eg_error);
GError *eg_error = NULL;
MonoString *o = NULL;
guint16 *ut;
glong items_written;
int l;

g_free (ut);
error_init (error);

l = strlen (text);

ut = g_utf8_to_utf16 (text, l, NULL, &items_written, &eg_error);

if (!eg_error) {
o = mono_string_new_utf16_checked (domain, ut, items_written, error);
} else {
mono_error_set_execution_engine (error, "String conversion error: %s", eg_error->message);
}

g_free (ut);

/*FIXME g_utf8_get_char, g_utf8_next_char and g_utf8_validate are not part of eglib.*/
#if 0
Expand Down

0 comments on commit dcdfb3c

Please sign in to comment.