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
pull/17390/head
Egor Pugin 5 years ago committed by GitHub
parent 29bbbaa0a7
commit 1bec7ca540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      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")

Loading…
Cancel
Save