summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSivan Nanthiran <nanthiran2005@gmail.com>2022-02-05 16:27:35 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-16 12:57:10 +0000
commitd40866a8f8c3483ad51f20c81e7a3f1d96b0a396 (patch)
tree61507b681d073d881b7fb466d07ac3ebe0844694
parente136b7b33c6b304d59199452c85acbe049dc4ccd (diff)
downloadqtbase-d40866a8f8c3483ad51f20c81e7a3f1d96b0a396.tar.gz
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>
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.mm6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm
index 38a427ab06..eba12e98f2 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.mm
+++ b/src/plugins/platforms/cocoa/qcocoascreen.mm
@@ -230,13 +230,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];