From 8e06a1084dc0a89e6393d7152ae4a20af16cd6e5 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:09:09 +0200 Subject: [PATCH] [iOS] Fix GDExtension init callback array reallocation. --- platform/ios/os_ios.mm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm index 68e6d4c934ce..16ac3acbec29 100644 --- a/platform/ios/os_ios.mm +++ b/platform/ios/os_ios.mm @@ -72,16 +72,15 @@ void add_ios_init_callback(init_callback cb) { if (ios_init_callbacks_count == ios_init_callbacks_capacity) { - void *new_ptr = realloc(ios_init_callbacks, sizeof(cb) * 32); + void *new_ptr = realloc(ios_init_callbacks, sizeof(cb) * (ios_init_callbacks_capacity + 32)); if (new_ptr) { ios_init_callbacks = (init_callback *)(new_ptr); ios_init_callbacks_capacity += 32; + } else { + ERR_FAIL_MSG("Unable to allocate memory for extension callbacks."); } } - if (ios_init_callbacks_capacity > ios_init_callbacks_count) { - ios_init_callbacks[ios_init_callbacks_count] = cb; - ++ios_init_callbacks_count; - } + ios_init_callbacks[ios_init_callbacks_count++] = cb; } void register_dynamic_symbol(char *name, void *address) {