Skip to content

Commit dcdfb3c

Browse files
committed
[runtime] Don't discard string conversion errors
1 parent 2bf7d1b commit dcdfb3c

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

mono/metadata/icall.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7094,6 +7094,8 @@ ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
70947094
mcpath = mono_string_new (mono_domain_get (), path);
70957095
g_free (path);
70967096

7097+
g_assert (mcpath);
7098+
70977099
return mcpath;
70987100
}
70997101

mono/metadata/object.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6248,24 +6248,25 @@ mono_string_new_checked (MonoDomain *domain, const char *text, MonoError *error)
62486248
{
62496249
MONO_REQ_GC_UNSAFE_MODE;
62506250

6251-
GError *eg_error = NULL;
6252-
MonoString *o = NULL;
6253-
guint16 *ut;
6254-
glong items_written;
6255-
int l;
6256-
6257-
error_init (error);
6258-
6259-
l = strlen (text);
6260-
6261-
ut = g_utf8_to_utf16 (text, l, NULL, &items_written, &eg_error);
6262-
6263-
if (!eg_error)
6264-
o = mono_string_new_utf16_checked (domain, ut, items_written, error);
6265-
else
6266-
g_error_free (eg_error);
6251+
GError *eg_error = NULL;
6252+
MonoString *o = NULL;
6253+
guint16 *ut;
6254+
glong items_written;
6255+
int l;
62676256

6268-
g_free (ut);
6257+
error_init (error);
6258+
6259+
l = strlen (text);
6260+
6261+
ut = g_utf8_to_utf16 (text, l, NULL, &items_written, &eg_error);
6262+
6263+
if (!eg_error) {
6264+
o = mono_string_new_utf16_checked (domain, ut, items_written, error);
6265+
} else {
6266+
mono_error_set_execution_engine (error, "String conversion error: %s", eg_error->message);
6267+
}
6268+
6269+
g_free (ut);
62696270

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

0 commit comments

Comments
 (0)