Skip to content

Commit 2e151ee

Browse files
authored
[mono] Avoid an assert if the class name table is too large. (#85952)
Fixes #85917.
1 parent f2d2a65 commit 2e151ee

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/mono/mono/mini/aot-compiler.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11646,11 +11646,15 @@ emit_class_name_table (MonoAotCompile *acfg)
1164611646
name_p = name_buf = (guint8 *)g_malloc0 (name_buf_size);
1164711647
#endif
1164811648

11649+
guint table_len = table->len;
11650+
if (table_size > 65000 || table->len > 65000) {
11651+
table_size = 0;
11652+
table_len = 0;
11653+
}
11654+
1164911655
/* FIXME: Optimize memory usage */
11650-
g_assert (table_size < 65000);
1165111656
encode_int16 (GINT_TO_UINT16 (table_size), p, &p);
11652-
g_assert (table->len < 65000);
11653-
for (guint i = 0; i < table->len; ++i) {
11657+
for (guint i = 0; i < table_len; ++i) {
1165411658
entry = (ClassNameTableEntry *)g_ptr_array_index (table, i);
1165511659
if (entry == NULL) {
1165611660
encode_int16 (0, p, &p);

src/mono/mono/mini/aot-runtime.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,6 +2639,9 @@ mono_aot_get_class_from_name (MonoImage *image, const char *name_space, const ch
26392639
table_size = amodule->class_name_table [0];
26402640
table = amodule->class_name_table + 1;
26412641

2642+
if (table_size == 0)
2643+
return FALSE;
2644+
26422645
if (name_space [0] == '\0')
26432646
full_name = g_strdup_printf ("%s", name);
26442647
else {

0 commit comments

Comments
 (0)