Skip to content

Commit 4994768

Browse files
committed
Fix possible NPE in iOS database module
1 parent 8a089c6 commit 4994768

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

ios/Firestack/FirestackDatabase.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,11 @@ - (id) init
491491
callback:(RCTResponseSenderBlock) callback)
492492
{
493493
NSString *key = [self getDBListenerKey:path withModifiers:modifiersString];
494+
NSArray *listenerKeys;
494495
FirestackDBReference *ref = [_dbReferences objectForKey:key];
495-
if (ref != nil) {
496+
if (ref == nil) {
497+
listenerKeys = @[];
498+
} else {
496499
if (eventName == nil || [eventName isEqualToString:@""]) {
497500
[ref cleanup];
498501
[_dbReferences removeObjectForKey:key];
@@ -502,12 +505,13 @@ - (id) init
502505
[_dbReferences removeObjectForKey:key];
503506
}
504507
}
508+
listenerKeys = [ref listenerKeys];
505509
}
506510
callback(@[[NSNull null], @{
507511
@"result": @"success",
508512
@"handle": path,
509513
@"modifiersString": modifiersString,
510-
@"remainingListeners": [ref listenerKeys],
514+
@"remainingListeners": listenerKeys,
511515
}]);
512516
}
513517

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-firestack",
3-
"version": "2.3.3",
3+
"version": "3.0.0-alpha",
44
"author": "Ari Lerner <ari@fullstack.io> (https://fullstackreact.com)",
55
"description": "A firebase v3 adapter",
66
"main": "index",

0 commit comments

Comments
 (0)