From 821783d809b1ef5a6aac0353cf1f283c42eb3f1a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 16 Jan 2020 01:04:38 +0300 Subject: SymbolInfo: get rid of a dangerous hack --- include/pdb/symbol.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include/pdb') diff --git a/include/pdb/symbol.hpp b/include/pdb/symbol.hpp index 2e24a5a..3e0ab17 100644 --- a/include/pdb/symbol.hpp +++ b/include/pdb/symbol.hpp @@ -40,18 +40,18 @@ public: SymbolInfo(); explicit SymbolInfo(const Impl& impl); - explicit operator Impl&() { return impl; } - explicit operator const Impl&() const { return impl; } + explicit operator Impl&() { return get_impl(); } + explicit operator const Impl&() const { return get_impl(); } Address get_displacement() const { return displacement; } void set_displacement(Address new_value) { displacement = new_value; } - std::string get_name() const { return {impl.Name, impl.NameLen}; } + std::string get_name() const { return {get_impl().Name, get_impl().NameLen}; } - Address get_offline_base() const { return impl.ModBase; } - Address get_offline_address() const { return impl.Address; } + Address get_offline_base() const { return get_impl().ModBase; } + Address get_offline_address() const { return get_impl().Address; } - symbol::Tag get_tag() const { return impl.Tag; } + symbol::Tag get_tag() const { return get_impl().Tag; } enum class Type : symbol::Tag { Function = symbol::SYM_TAG_FUNCTION, @@ -68,8 +68,8 @@ private: std::array buffer; Address displacement = 0; -protected: - Impl& impl; + const Impl& get_impl() const { return *reinterpret_cast(buffer.data()); } + Impl& get_impl() { return *reinterpret_cast(buffer.data()); } }; class Symbol : public SymbolInfo { -- cgit v1.2.3