From ab6ce05aec5b0f74888fe0972bc444becca90e96 Mon Sep 17 00:00:00 2001 From: mjk Date: Fri, 19 Mar 2021 22:44:38 +0000 Subject: [PATCH] handle empty hresult_error message specially --- plugins/windows-notification/api/src/ginvoke.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/windows-notification/api/src/ginvoke.cpp b/plugins/windows-notification/api/src/ginvoke.cpp index 5e5d27a7..407c18b3 100644 --- a/plugins/windows-notification/api/src/ginvoke.cpp +++ b/plugins/windows-notification/api/src/ginvoke.cpp @@ -16,10 +16,16 @@ namespace glib::impl const char *ptr = nullptr; try { - ptr = wsview_to_char(e.message()); - std::string msg{ptr}; - g_free(const_cast(ptr)); // WTF? Deletion is not modification! - return {{ e.code(), {std::move(msg)} }}; + const auto wmsg = std::wstring_view{e.message()}; + if (not wmsg.empty()) + { + ptr = wsview_to_char(wmsg); + std::string msg{ptr}; + g_free(const_cast(ptr)); // WTF? Deletion is not modification! + return {{ e.code(), {std::move(msg)} }}; + } + else + return {{ e.code(), {""} }}; } catch (...) {