Skip to content

Commit

Permalink
Mono: Fix Array IndexOutOfRangeException not being thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
neikeq committed Jul 3, 2019
1 parent f5f7244 commit 3abe696
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/mono/glue/collections_glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ void godot_icall_Array_Dtor(Array *ptr) {
}

MonoObject *godot_icall_Array_At(Array *ptr, int index) {
if (index < 0 || index > ptr->size()) {
if (index < 0 || index >= ptr->size()) {
GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range());
return NULL;
}
return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index));
}

MonoObject *godot_icall_Array_At_Generic(Array *ptr, int index, uint32_t type_encoding, GDMonoClass *type_class) {
if (index < 0 || index > ptr->size()) {
if (index < 0 || index >= ptr->size()) {
GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range());
return NULL;
}
return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index), ManagedType(type_encoding, type_class));
}

void godot_icall_Array_SetAt(Array *ptr, int index, MonoObject *value) {
if (index < 0 || index > ptr->size()) {
if (index < 0 || index >= ptr->size()) {
GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range());
return;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ MonoBoolean godot_icall_Array_Remove(Array *ptr, MonoObject *item) {
}

void godot_icall_Array_RemoveAt(Array *ptr, int index) {
if (index < 0 || index > ptr->size()) {
if (index < 0 || index >= ptr->size()) {
GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range());
return;
}
Expand Down

0 comments on commit 3abe696

Please sign in to comment.