Skip to content

Commit 048be1a

Browse files
committed
Fixes #1184
- Prevent deadlock by copying estimatedData before traversal
1 parent 66d1f8b commit 048be1a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Parse/Parse/PFObject.m

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,19 +1623,20 @@ - (BOOL)needsDefaultACL {
16231623

16241624
- (NSDictionary *)_collectFetchedObjects {
16251625
NSMutableDictionary *fetchedObjects = [NSMutableDictionary dictionary];
1626+
NSDictionary *dictionary;
16261627
@synchronized (lock) {
1627-
NSDictionary *dictionary = _estimatedData.dictionaryRepresentation;
1628-
[PFInternalUtils traverseObject:dictionary usingBlock:^id(id obj) {
1629-
if ([obj isKindOfClass:[PFObject class]]) {
1630-
PFObject *object = obj;
1631-
NSString *objectId = object.objectId;
1632-
if (objectId && object.dataAvailable) {
1633-
fetchedObjects[objectId] = object;
1634-
}
1628+
dictionary = [_estimatedData.dictionaryRepresentation copy];
1629+
}
1630+
[PFInternalUtils traverseObject:dictionary usingBlock:^id(id obj) {
1631+
if ([obj isKindOfClass:[PFObject class]]) {
1632+
PFObject *object = obj;
1633+
NSString *objectId = object.objectId;
1634+
if (objectId && object.dataAvailable) {
1635+
fetchedObjects[objectId] = object;
16351636
}
1636-
return obj;
1637-
}];
1638-
}
1637+
}
1638+
return obj;
1639+
}];
16391640
return fetchedObjects;
16401641
}
16411642

0 commit comments

Comments
 (0)