fix: wrap OnWindowMessage w/ handlescope (#24716)

This commit is contained in:
Jeremy Rose 2020-07-28 15:09:56 -07:00 committed by GitHub
parent b6321cc22d
commit 834408a50f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,7 @@
#include "shell/browser/api/electron_api_menu.h"
#include "shell/browser/api/electron_api_view.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/color_util.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/file_path_converter.h"
@ -296,9 +297,12 @@ void BaseWindow::OnNewWindowForTab() {
#if defined(OS_WIN)
void BaseWindow::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
if (IsWindowMessageHooked(message)) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::Locker locker(isolate);
v8::HandleScope scope(isolate);
messages_callback_map_[message].Run(
ToBuffer(isolate(), static_cast<void*>(&w_param), sizeof(WPARAM)),
ToBuffer(isolate(), static_cast<void*>(&l_param), sizeof(LPARAM)));
ToBuffer(isolate, static_cast<void*>(&w_param), sizeof(WPARAM)),
ToBuffer(isolate, static_cast<void*>(&l_param), sizeof(LPARAM)));
}
}
#endif