mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 21:41:51 +02:00
supress warning C26451 arithmetic overflow
This commit is contained in:
committed by
Enrico Giordani
parent
11396015fb
commit
799ac545a2
@@ -100,17 +100,19 @@ void send_message_to_webview(const std::wstring& msg) {
|
|||||||
if (g_main_wnd != nullptr && wm_data_for_webview != 0) {
|
if (g_main_wnd != nullptr && wm_data_for_webview != 0) {
|
||||||
// Allocate the COPYDATASTRUCT and message to pass to the Webview.
|
// Allocate the COPYDATASTRUCT and message to pass to the Webview.
|
||||||
// This is needed in order to use PostMessage, since COM calls to
|
// This is needed in order to use PostMessage, since COM calls to
|
||||||
// webview_control.InvokeScriptAsync can't be made from
|
// webview_control.InvokeScriptAsync can't be made from other threads.
|
||||||
PCOPYDATASTRUCT copy_data_message = new COPYDATASTRUCT();
|
|
||||||
const wchar_t* orig_msg = msg.c_str();
|
PCOPYDATASTRUCT message = new COPYDATASTRUCT();
|
||||||
DWORD orig_len = (DWORD)wcslen(orig_msg);
|
DWORD buff_size = (DWORD)(msg.length() + 1);
|
||||||
wchar_t* copy_msg = new wchar_t[orig_len + 1];
|
|
||||||
wcscpy_s(copy_msg, orig_len + 1, orig_msg);
|
// 'wnd_static_proc()' will free the buffer allocated here.
|
||||||
copy_data_message->dwData = SEND_TO_WEBVIEW_MSG;
|
wchar_t* buffer = new wchar_t[buff_size];
|
||||||
copy_data_message->cbData = (orig_len + 1) * sizeof(wchar_t);
|
|
||||||
copy_data_message->lpData = (PVOID)copy_msg;
|
wcscpy_s(buffer, buff_size, msg.c_str());
|
||||||
PostMessage(g_main_wnd, wm_data_for_webview, (WPARAM)g_main_wnd, (LPARAM)copy_data_message);
|
message->dwData = SEND_TO_WEBVIEW_MSG;
|
||||||
// wnd_static_proc will be responsible for freeing these.
|
message->cbData = buff_size * sizeof(wchar_t);
|
||||||
|
message->lpData = (PVOID)buffer;
|
||||||
|
PostMessage(g_main_wnd, wm_data_for_webview, (WPARAM)g_main_wnd, (LPARAM)message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user