1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-29 21:48:52 -05:00

Cocoa: Fix potential leak of CFNumber object

Spotted by Clang static analysis.

(cherry picked from commit a2674a9034)
This commit is contained in:
Camilla Löwy 2020-07-23 18:55:29 +02:00 committed by Camilla Löwy
parent 2a5ac9a6d6
commit b8a6254a26
2 changed files with 14 additions and 6 deletions

View File

@ -124,6 +124,8 @@ information on what to include when reporting a bug.
- [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169) - [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
- [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16 - [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
(#1635) (#1635)
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
could leak memory
- [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636) - [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636)
- [X11] Bugfix: Xlib errors caused by other parts of the application could be - [X11] Bugfix: Xlib errors caused by other parts of the application could be
reported as GLFW errors reported as GLFW errors

View File

@ -277,14 +277,20 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID)
CFSTR("IOFBCurrentPixelCount"), CFSTR("IOFBCurrentPixelCount"),
kCFAllocatorDefault, kCFAllocatorDefault,
kNilOptions); kNilOptions);
if (!clockRef || !countRef)
break;
uint32_t clock = 0, count = 0; uint32_t clock = 0, count = 0;
CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
CFNumberGetValue(countRef, kCFNumberIntType, &count); if (clockRef)
CFRelease(clockRef); {
CFRelease(countRef); CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
CFRelease(clockRef);
}
if (countRef)
{
CFNumberGetValue(countRef, kCFNumberIntType, &count);
CFRelease(countRef);
}
if (clock > 0 && count > 0) if (clock > 0 && count > 0)
refreshRate = clock / (double) count; refreshRate = clock / (double) count;