Skip to content

Commit 1bec7ca

Browse files
authored
Merge pull request opencv#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
1 parent 29bbbaa commit 1bec7ca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

modules/core/src/system.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,11 @@ inline size_t parseOption(const std::string &value)
19611961
}
19621962
cv::String valueStr = value.substr(0, pos);
19631963
cv::String suffixStr = value.substr(pos, value.length() - pos);
1964-
int v = atoi(valueStr.c_str());
1964+
#ifdef CV_CXX11
1965+
size_t v = (size_t)std::stoull(valueStr);
1966+
#else
1967+
size_t v = (size_t)atol(valueStr.c_str());
1968+
#endif
19651969
if (suffixStr.length() == 0)
19661970
return v;
19671971
else if (suffixStr == "MB" || suffixStr == "Mb" || suffixStr == "mb")

0 commit comments

Comments
 (0)