aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--include/pdb/symbol.hpp5
-rw-r--r--src/symbol.cpp4
2 files changed, 7 insertions, 2 deletions
diff --git a/include/pdb/symbol.hpp b/include/pdb/symbol.hpp
index 6a62e22..f843df7 100644
--- a/include/pdb/symbol.hpp
+++ b/include/pdb/symbol.hpp
@@ -15,6 +15,7 @@
#include <climits>
#include <cstddef>
#include <string>
+#include <type_traits>
namespace pdb {
namespace symbol {
@@ -61,7 +62,9 @@ public:
bool is_function() const { return get_type() == Type::Function; }
private:
- static constexpr std::size_t max_buffer_size = sizeof(Impl) + MAX_SYM_NAME - 1;
+ static constexpr std::size_t char_size = sizeof(std::remove_extent<decltype(Impl::Name)>::type);
+ static_assert(char_size == sizeof(wchar_t), "Aren't we using the wide WinAPI?");
+ static constexpr std::size_t max_buffer_size = sizeof(Impl) + (MAX_SYM_NAME - 1) * char_size;
std::array<unsigned char, max_buffer_size> buffer;
Address displacement = 0;
diff --git a/src/symbol.cpp b/src/symbol.cpp
index 1973f0b..3b0f5d9 100644
--- a/src/symbol.cpp
+++ b/src/symbol.cpp
@@ -16,13 +16,15 @@
#include <cstring>
#include <stdexcept>
#include <string>
+#include <type_traits>
namespace pdb {
namespace {
std::size_t calc_size(const SymbolInfo::Impl& impl) {
try {
- return SafeInt<std::size_t>{impl.SizeOfStruct} + impl.NameLen - 1;
+ 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"};
}