summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-11-11 15:24:59 -0800
committerMinh Nguyễn <mxn@1ec5.org>2015-11-12 10:46:47 -0800
commit6748b6155e0bdb61aa33ecfe467711ce7e1189c3 (patch)
tree5850f61ba16ce77542bedab0ae85bc9000417bb1 /src
parentaae7f90e37ac9c074c3bc2205116d9827045027c (diff)
downloadqtlocation-mapboxgl-6748b6155e0bdb61aa33ecfe467711ce7e1189c3.tar.gz
[core] Fixed bit-shifting error in exponential backoff
This change fixes a bug introduced in 4d5c6333be52aae4a9c72f4b01941e16ead503f4 for #2727. 1 << 32 would exceed the size of int64_t. The static analyzer reported undefined behavior here because std::min() might or might not return 32.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/storage/default_file_source.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mbgl/storage/default_file_source.cpp b/src/mbgl/storage/default_file_source.cpp
index 64c802d770..bfab5bfcaf 100644
--- a/src/mbgl/storage/default_file_source.cpp
+++ b/src/mbgl/storage/default_file_source.cpp
@@ -325,12 +325,12 @@ int64_t DefaultFileRequest::getRetryTimeout() const {
if (failedRequests <= graceRetries) {
timeout = 1;
} else {
- timeout = 1 << std::min(failedRequests - graceRetries, 32);
+ timeout = 1 << std::min(failedRequests - graceRetries, 31);
}
} break;
case Response::Error::Reason::Connection: {
// Exponential backoff
- timeout = 1 << std::min(failedRequests - 1, 32);
+ timeout = 1 << std::min(failedRequests - 1, 31);
} break;
default:
// Do not retry due to error.