Browse Source

Merge pull request #55039 from BastiaanOlij/fix_gdnative_array_index

Fix array access in gdextensions
Rémi Verschelde 3 years ago
parent
commit
3c04522ece
1 changed files with 2 additions and 2 deletions
  1. 2 2
      core/extension/gdnative_interface.cpp

+ 2 - 2
core/extension/gdnative_interface.cpp

@@ -774,13 +774,13 @@ static GDNativeTypePtr gdnative_packed_vector3_array_operator_index_const(const
 static GDNativeVariantPtr gdnative_array_operator_index(GDNativeTypePtr p_self, GDNativeInt p_index) {
 static GDNativeVariantPtr gdnative_array_operator_index(GDNativeTypePtr p_self, GDNativeInt p_index) {
 	Array *self = (Array *)p_self;
 	Array *self = (Array *)p_self;
 	ERR_FAIL_INDEX_V(p_index, self->size(), nullptr);
 	ERR_FAIL_INDEX_V(p_index, self->size(), nullptr);
-	return (GDNativeTypePtr)&self[p_index];
+	return (GDNativeVariantPtr)&self->operator[](p_index);
 }
 }
 
 
 static GDNativeVariantPtr gdnative_array_operator_index_const(const GDNativeTypePtr p_self, GDNativeInt p_index) {
 static GDNativeVariantPtr gdnative_array_operator_index_const(const GDNativeTypePtr p_self, GDNativeInt p_index) {
 	const Array *self = (const Array *)p_self;
 	const Array *self = (const Array *)p_self;
 	ERR_FAIL_INDEX_V(p_index, self->size(), nullptr);
 	ERR_FAIL_INDEX_V(p_index, self->size(), nullptr);
-	return (GDNativeTypePtr)&self[p_index];
+	return (GDNativeVariantPtr)&self->operator[](p_index);
 }
 }
 
 
 /* OBJECT API */
 /* OBJECT API */