From 29d886718cc238958f8492fdadc5f4af01f8a022 Mon Sep 17 00:00:00 2001 From: Double Sine Date: Tue, 15 Jan 2019 17:19:09 +0800 Subject: [PATCH] Fix a mistake that will return an invalid pointer --- navicat-patcher/ExceptionSystem.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/navicat-patcher/ExceptionSystem.hpp b/navicat-patcher/ExceptionSystem.hpp index c4e55b2..e9aec59 100644 --- a/navicat-patcher/ExceptionSystem.hpp +++ b/navicat-patcher/ExceptionSystem.hpp @@ -5,13 +5,15 @@ class SystemError : public Exception { private: const std::error_code _ErrorCode; + const std::string _ErrorString; public: SystemError(const char* FileName, int Line, unsigned long Code, const char* Message) noexcept : Exception(FileName, Line, Message), - _ErrorCode(Code, std::system_category()) {} + _ErrorCode(Code, std::system_category()), + _ErrorString(_ErrorCode.message()) {} virtual bool HasErrorCode() const noexcept override { return true; @@ -22,7 +24,7 @@ public: } virtual const char* ErrorString() const noexcept override { - return _ErrorCode.message().c_str(); + return _ErrorString.c_str(); } };