From 470926db08ad0c301599a6b3ce124bd4b8823827 Mon Sep 17 00:00:00 2001 From: libla Date: Thu, 28 Jul 2016 00:57:47 +0800 Subject: [PATCH 1/2] * Remove replace invalid chars operator in wstring_to_utf8 because it replace all non-ascii character to 0xFFFD, then will break string content. --- src/ScriptingCore/utf8_tools.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ScriptingCore/utf8_tools.cpp b/src/ScriptingCore/utf8_tools.cpp index 2db1c497..98fc1335 100644 --- a/src/ScriptingCore/utf8_tools.cpp +++ b/src/ScriptingCore/utf8_tools.cpp @@ -36,12 +36,10 @@ namespace FB { std::string wstring_to_utf8(const std::wstring& src) { std::string out_str; - std::wstring in_str; - utf8::replace_invalid(src.begin(), src.end(), std::back_inserter(in_str)); -#ifdef _WIN32 - utf8::utf16to8(in_str.begin(), in_str.end(), std::back_inserter(out_str)); -#else - utf8::utf32to8(in_str.begin(), in_str.end(), std::back_inserter(out_str)); +#ifdef _WIN32 + utf8::utf16to8(src.begin(), src.end(), std::back_inserter(out_str)); +#else + utf8::utf32to8(src.begin(), src.end(), std::back_inserter(out_str)); #endif return out_str; } From 0304a7cd5a52668cc638bf50b2e0506eef67a147 Mon Sep 17 00:00:00 2001 From: libla Date: Thu, 4 Aug 2016 01:34:00 +0800 Subject: [PATCH 2/2] fix memory leaks when using stream API --- src/ActiveXCore/axstream.cpp | 1 + src/ActiveXCore/axstream_impl.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ActiveXCore/axstream.cpp b/src/ActiveXCore/axstream.cpp index 1a4119e3..6e103eac 100644 --- a/src/ActiveXCore/axstream.cpp +++ b/src/ActiveXCore/axstream.cpp @@ -141,6 +141,7 @@ void ActiveXStream::signalRequestCompleted(ActiveXStreamRequestPtr request, bool signalCompleted( success ); close(); } + request->stop(); } void ActiveXStream::signalCacheFilename(const std::wstring& cacheFilename) diff --git a/src/ActiveXCore/axstream_impl.cpp b/src/ActiveXCore/axstream_impl.cpp index 84c4c11c..c54393e5 100644 --- a/src/ActiveXCore/axstream_impl.cpp +++ b/src/ActiveXCore/axstream_impl.cpp @@ -283,7 +283,9 @@ STDMETHODIMP ActiveXBindStatusCallback::OnProgress(ULONG ulProgress, ULONG ulPro STDMETHODIMP ActiveXBindStatusCallback::OnStopBinding(HRESULT hrStatus, LPCWSTR pszError) { - if ( m_request->stream ) m_request->stream->signalRequestCompleted( m_request, !FAILED(hrStatus) ); + ActiveXStreamPtr stream = m_request->stream; + if (stream) + stream->signalRequestCompleted(m_request, !FAILED(hrStatus)); if (m_pbinding) {