diff options
author | Sivan Nanthiran <nanthiran2005@gmail.com> | 2022-02-05 16:27:35 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-02-10 13:52:49 +0000 |
commit | a09215d415c6e6a92d67b49e72686cbe087ee161 (patch) | |
tree | bc0962f1f1dc512589280dd065f8a5640e7fdfbe /src/plugins | |
parent | a371be6e945f72e2916a99d8816026dda904f980 (diff) |
Change comparison data type to fix int overflow
Since the value returned by CGDisplaySerialNumber is uint32_t,
comparing it with a long data type can cause overflow when the
value is greater than or equal to 2^31. And since this is a serial
number, in some machine this value can be greater than 2^31.
In those machines, QScreen::name will be empty due to the failed
check here.
Change-Id: Ia037ba9e7a6d8025cc4b41c1b428eba38455330d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit cb9ef46c77e0faf78658831063d0e1cc3255e30c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoascreen.mm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 82fd1c44df..b3a65f3e65 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -232,13 +232,13 @@ static QString displayName(CGDirectDisplayID displayID) NSDictionary *info = [(__bridge NSDictionary*)IODisplayCreateInfoDictionary( display, kIODisplayOnlyPreferredName) autorelease]; - if ([[info objectForKey:@kDisplayVendorID] longValue] != CGDisplayVendorNumber(displayID)) + if ([[info objectForKey:@kDisplayVendorID] unsignedIntValue] != CGDisplayVendorNumber(displayID)) continue; - if ([[info objectForKey:@kDisplayProductID] longValue] != CGDisplayModelNumber(displayID)) + if ([[info objectForKey:@kDisplayProductID] unsignedIntValue] != CGDisplayModelNumber(displayID)) continue; - if ([[info objectForKey:@kDisplaySerialNumber] longValue] != CGDisplaySerialNumber(displayID)) + if ([[info objectForKey:@kDisplaySerialNumber] unsignedIntValue] != CGDisplaySerialNumber(displayID)) continue; NSDictionary *localizedNames = [info objectForKey:@kDisplayProductName]; |