From 6ce5d092473f3fed16f509a3e60480de4a04ece3 Mon Sep 17 00:00:00 2001 From: Maximus5 Date: Wed, 25 Oct 2017 12:37:10 +0300 Subject: [PATCH] gh-1293: LastError was erased on `printf`. --- src/ConEmuHk/Ansi.cpp | 2 ++ src/common/HandleKeeper.cpp | 3 +++ src/common/WCodePage.cpp | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ConEmuHk/Ansi.cpp b/src/ConEmuHk/Ansi.cpp index 70e0e35d45..bd643bb31c 100644 --- a/src/ConEmuHk/Ansi.cpp +++ b/src/ConEmuHk/Ansi.cpp @@ -3831,6 +3831,8 @@ void CEAnsi::StorePromptBegin() //static CEAnsi* CEAnsi::Object(bool bForceCreate /*= false*/) { + CLastErrorGuard errGuard; + if (!AnsiTlsIndex) { AnsiTlsIndex = TlsAlloc(); diff --git a/src/common/HandleKeeper.cpp b/src/common/HandleKeeper.cpp index 5bf6f850b2..4fdbf4f788 100644 --- a/src/common/HandleKeeper.cpp +++ b/src/common/HandleKeeper.cpp @@ -30,6 +30,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "HandleKeeper.h" +#include "WErrGuard.h" #ifdef _DEBUG #include "MStrDup.h" @@ -280,6 +281,8 @@ bool HandleKeeper::AllocHandleInfo(HANDLE h, HandleSource source, DWORD access, bool HandleKeeper::QueryHandleInfo(HANDLE h, HandleInformation& Info, bool AnsiOutExpected) { + CLastErrorGuard errGuard; + if (!h || (h == INVALID_HANDLE_VALUE)) return false; bool bFound = false; diff --git a/src/common/WCodePage.cpp b/src/common/WCodePage.cpp index 9d1fdb338b..21faa739c0 100644 --- a/src/common/WCodePage.cpp +++ b/src/common/WCodePage.cpp @@ -30,6 +30,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define HIDE_USE_EXCEPTION_INFO #include "Common.h" #include "WCodePage.h" +#include "WErrGuard.h" void CpCvt::ResetBuffer() { @@ -38,6 +39,8 @@ void CpCvt::ResetBuffer() CpCvtResult CpCvt::SetCP(UINT anCP) { + CLastErrorGuard errGuard; + if (bInitialized && (nCP == anCP)) return ccr_OK; @@ -93,7 +96,7 @@ CpCvtResult CpCvt::Convert(char c, wchar_t& wc) } goto wrap; } - + // Continuation byte (10xxxxxx)? if (blen && ((bt & 0xC0/*11xxxxxx*/) != 0x80/*10xxxxxx*/)) {