From daaa72d82df6b9e5e2c1247c10792d4b12683541 Mon Sep 17 00:00:00 2001 From: danielhover <49653670+danielhover@users.noreply.github.com> Date: Fri, 25 Jun 2021 16:46:21 -0700 Subject: [PATCH] fix(storage, ios): dont enumerate on dictionary being mutated (#5455) Avoid a possible crash during storage dealloc by iterating on a copy of the array being mutated instead of the array itself --- packages/storage/ios/RNFBStorage/RNFBStorageModule.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/storage/ios/RNFBStorage/RNFBStorageModule.m b/packages/storage/ios/RNFBStorage/RNFBStorageModule.m index 0a6ab6f2dc..1887acddb4 100644 --- a/packages/storage/ios/RNFBStorage/RNFBStorageModule.m +++ b/packages/storage/ios/RNFBStorage/RNFBStorageModule.m @@ -61,13 +61,13 @@ - (id)init { } - (void)dealloc { - for (NSString *key in PENDING_TASKS) { + for (NSString *key in [PENDING_TASKS allKeys]) { [PENDING_TASKS removeObjectForKey:key]; } } - (void)invalidate { - for (NSString *key in PENDING_TASKS) { + for (NSString *key in [PENDING_TASKS allKeys]) { [PENDING_TASKS removeObjectForKey:key]; } }