From 7149f90898ab0ed8d4ec55a36a85aeead66e55e7 Mon Sep 17 00:00:00 2001 From: "Antoine Jacquemin (Rubicon)" Date: Wed, 26 Jun 2019 00:51:08 +1000 Subject: [PATCH] Fix issue for Int.max overflow (#211) * Fix issue for Int.max overflow For Iphone 5c and lower the processors is built on a 32-bit architecture. So any Int will be 32 bit. For these device we need to use Int64 as Date().timeIntervalSince1970 * 1000 will be out of range. * suggestion fix * ageInMilliseconds theoretically can cause a fatal exception on 32-bit arch --- src/PrebidMobile/PrebidMobile/BidManager.swift | 6 +++--- src/PrebidMobile/PrebidMobile/RequestBuilder.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PrebidMobile/PrebidMobile/BidManager.swift b/src/PrebidMobile/PrebidMobile/BidManager.swift index 0f081558a..971b93e5f 100644 --- a/src/PrebidMobile/PrebidMobile/BidManager.swift +++ b/src/PrebidMobile/PrebidMobile/BidManager.swift @@ -46,7 +46,7 @@ import Foundation if (!Prebid.shared.timeoutUpdated) { let tmax = self.getTmaxRequest(data!) if (tmax > 0) { - Prebid.shared.timeoutMillis = min(demandFetchEndTime - demandFetchStartTime + tmax + 200, .PB_Request_Timeout) + Prebid.shared.timeoutMillis = min(Int(demandFetchEndTime - demandFetchStartTime) + tmax + 200, .PB_Request_Timeout) Prebid.shared.timeoutUpdated = true } } @@ -144,8 +144,8 @@ import Foundation } - func getCurrentMillis() -> Int { - return Int(Date().timeIntervalSince1970 * 1000) + func getCurrentMillis() -> Int64 { + return Int64(Date().timeIntervalSince1970 * 1000) } func getTmaxRequest(_ data: Data) -> Int { diff --git a/src/PrebidMobile/PrebidMobile/RequestBuilder.swift b/src/PrebidMobile/PrebidMobile/RequestBuilder.swift index 7fe9cc718..bd7600e87 100644 --- a/src/PrebidMobile/PrebidMobile/RequestBuilder.swift +++ b/src/PrebidMobile/PrebidMobile/RequestBuilder.swift @@ -247,7 +247,7 @@ import AdSupport let locationTimestamp: Date? = Location.shared.location?.timestamp let ageInSeconds: TimeInterval = -1.0 * (locationTimestamp?.timeIntervalSinceNow ?? 0.0) - let ageInMilliseconds = Int(ageInSeconds * 1000) + let ageInMilliseconds = Int64(ageInSeconds * 1000) geoDict["lastfix"] = ageInMilliseconds geoDict["accuracy"] = Int(Location.shared.location?.horizontalAccuracy ?? 0)