From f6af7c442df3e569492ced730e70d1bc72356c5e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 15 May 2021 21:22:50 +0300 Subject: get rid of SafeInt --- src/process.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/process.cpp') diff --git a/src/process.cpp b/src/process.cpp index 683312c..adb4b96 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -5,11 +5,11 @@ #include -#include #include #include +#include #include #include #include @@ -41,9 +41,10 @@ public: if (size < min_size) { size = min_size; } else { - if (!SafeMultiply(size, 2, size)) { + // Check if we can still multiply by two. + if (std::numeric_limits::max() - size < size) throw std::range_error{"couldn't allocate buffer sufficient for a file path"}; - } + size *= 2; } data.resize(size); } -- cgit v1.2.3