Skip to content

Fixes issue related to heap corruption #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Parse/Internal/PFEventuallyQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extern NSTimeInterval const PFEventuallyQueueDefaultTimeoutRetryInterval;
- (void)start NS_REQUIRES_SUPER;
- (void)resume NS_REQUIRES_SUPER;
- (void)pause NS_REQUIRES_SUPER;
- (void)stop NS_REQUIRES_SUPER;
- (void)terminate NS_REQUIRES_SUPER;
- (void)removeAllCommands NS_REQUIRES_SUPER;

@end
Expand Down
10 changes: 4 additions & 6 deletions Parse/Internal/PFEventuallyQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ - (instancetype)initWithDataSource:(id<PFCommandRunnerProvider>)dataSource
return self;
}

- (void)dealloc {
[self _stopMonitoringNetworkReachability];
}

///--------------------------------------
#pragma mark - Enqueueing Commands
///--------------------------------------
Expand Down Expand Up @@ -197,7 +193,8 @@ - (void)pause {
dispatch_suspend(_processingQueueSource);
}

- (void)stop {
- (void)terminate {
[self _stopMonitoringNetworkReachability];
dispatch_source_cancel(_processingQueueSource);
}

Expand Down Expand Up @@ -383,7 +380,6 @@ - (void)_stopMonitoringNetworkReachability {
[[PFReachability sharedParseReachability] removeListener:self];

self.monitorsReachability = NO;
self.connected = YES;
#endif
}

Expand All @@ -393,9 +389,11 @@ - (void)_stopMonitoringNetworkReachability {

/** Manually sets the network connection status. */
- (void)setConnected:(BOOL)connected {
@weakify(self);
BFTaskCompletionSource *barrier = [BFTaskCompletionSource taskCompletionSource];
dispatch_async(_processingQueue, ^{
dispatch_sync(_synchronizationQueue, ^{
@strongify(self);
if (self.connected != connected) {
_connected = connected;
if (connected) {
Expand Down
2 changes: 2 additions & 0 deletions Parse/Internal/PFReachability.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ - (void)addListener:(id<PFReachabilityListener>)listener {
}

- (void)removeListener:(id<PFReachabilityListener>)listener {
@weakify(listener);
dispatch_barrier_sync(_synchronizationQueue, ^{
@strongify(listener);
[_listenersArray filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
id weakObject = [evaluatedObject weakObject];
return (weakObject == nil || weakObject == listener);
Expand Down
4 changes: 2 additions & 2 deletions Parse/Internal/ParseManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ - (PFEventuallyQueue *)eventuallyQueue {
if (commandCache.commandCount > 0) {
[commandCache removeAllCommands];
}
// we won't need it after stop everything...
[commandCache stop];
// we won't need it after, terminate...
[commandCache terminate];
}
}
#endif
Expand Down