From 1bec7ca540541dc1e6dc7c9dc72303d0480365f7 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Mon, 25 May 2020 23:25:18 +0300 Subject: [PATCH] Merge pull request #17352 from egorpugin:patch-2 * Fix integer overflow in parseOption(). Previous code does not work for values like 100000MB. * Fix warning during 32-bit build on inactive code path. * fix build without C++11 --- modules/core/src/system.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 3c0588c355..fcb9ea45ef 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -1961,7 +1961,11 @@ inline size_t parseOption(const std::string &value) } cv::String valueStr = value.substr(0, pos); cv::String suffixStr = value.substr(pos, value.length() - pos); - int v = atoi(valueStr.c_str()); +#ifdef CV_CXX11 + size_t v = (size_t)std::stoull(valueStr); +#else + size_t v = (size_t)atol(valueStr.c_str()); +#endif if (suffixStr.length() == 0) return v; else if (suffixStr == "MB" || suffixStr == "Mb" || suffixStr == "mb")