summaryrefslogtreecommitdiffstatshomepage
path: root/src/symbol.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-05-15 21:22:50 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-05-15 21:22:50 +0300
commitf6af7c442df3e569492ced730e70d1bc72356c5e (patch)
treebd18c18acbc131bd43de99c9f03f698eff479a82 /src/symbol.cpp
parentworkflows/ci: build using VS 2015 also (diff)
downloadwinapi-debug-f6af7c442df3e569492ced730e70d1bc72356c5e.tar.gz
winapi-debug-f6af7c442df3e569492ced730e70d1bc72356c5e.zip
get rid of SafeInt
Diffstat (limited to '')
-rw-r--r--src/symbol.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/symbol.cpp b/src/symbol.cpp
index ad7bd3f..9f5e11d 100644
--- a/src/symbol.cpp
+++ b/src/symbol.cpp
@@ -5,7 +5,6 @@
#include <pdb/all.hpp>
-#include <SafeInt.hpp>
#include <boost/nowide/convert.hpp>
#include <dbghelp.h>
@@ -13,6 +12,7 @@
#include <cstddef>
#include <cstring>
+#include <limits>
#include <stdexcept>
#include <string>
#include <type_traits>
@@ -21,21 +21,17 @@ namespace pdb {
namespace {
std::size_t calc_size(const SymbolInfo::Impl& impl) {
- try {
- static constexpr auto char_size = sizeof(std::remove_extent<decltype(impl.Name)>::type);
- return SafeInt<std::size_t>{impl.SizeOfStruct} + (impl.NameLen - 1) * char_size;
- } catch (const SafeIntException&) {
- throw std::runtime_error{"invalid SYMBOL_INFO size"};
- }
+ static constexpr auto char_size = sizeof(std::remove_extent<decltype(impl.Name)>::type);
+ return impl.SizeOfStruct + (impl.NameLen - 1) * char_size;
}
unsigned long cast_line_number(DWORD impl) {
unsigned long dest = 0;
- if (!SafeCast(impl, dest))
+ if (impl > std::numeric_limits<decltype(dest)>::max())
throw std::runtime_error{"invalid line number"};
- return dest;
+ return static_cast<decltype(dest)>(dest);
}
} // namespace