Skip to content

Commit 856ecd6

Browse files
committed
Fix leak of display mode
1 parent 3440b7c commit 856ecd6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

SDWebImage/Core/SDWebImageDownloader.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
BOOL SDWebImageDownloaderOperationGetCompleted(id<SDWebImageDownloaderOperation> operation) {
2727
NSCParameterAssert(operation);
2828
NSNumber *value = objc_getAssociatedObject(operation, SDWebImageDownloaderOperationKey);
29-
if (value) {
29+
if (value != nil) {
3030
return value.boolValue;
3131
} else {
3232
return NO;

SDWebImage/Private/SDDisplayLink.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,14 @@ - (NSTimeInterval)duration {
116116
// Supports Pro display 120Hz
117117
CGDirectDisplayID display = CVDisplayLinkGetCurrentCGDisplay(_displayLink);
118118
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(display);
119-
double refreshRate = CGDisplayModeGetRefreshRate(mode);
120-
if (refreshRate > 0) {
121-
duration = 1.0 / refreshRate;
119+
if (mode) {
120+
double refreshRate = CGDisplayModeGetRefreshRate(mode);
121+
if (refreshRate > 0) {
122+
duration = 1.0 / refreshRate;
123+
} else {
124+
duration = kSDDisplayLinkInterval;
125+
}
126+
CGDisplayModeRelease(mode);
122127
} else {
123128
duration = kSDDisplayLinkInterval;
124129
}

0 commit comments

Comments
 (0)