diff --git a/cpp/winsharedutils/webview2_extra.cpp b/cpp/winsharedutils/webview2_extra.cpp index 062bf283..45a9dd56 100644 --- a/cpp/winsharedutils/webview2_extra.cpp +++ b/cpp/winsharedutils/webview2_extra.cpp @@ -251,10 +251,9 @@ DECLARE_API void *add_ContextMenuRequested(void *m_host, int index, const wchar_ ICoreWebView2ContextMenuItem *sender, IUnknown *args) { - LPWSTR selecttext; + wil::unique_cotaskmem_string selecttext; CHECK_FAILURE(target->get_SelectionText(&selecttext)); - callback(selecttext); - // 不需要free,free反而会崩溃 + callback(selecttext.get()); return S_OK; }) .Get(),