From 41088ef0cb7baabc8dd19dc3de90f57d5608f2e7 Mon Sep 17 00:00:00 2001 From: FabianLars Date: Sun, 23 Feb 2025 17:43:55 +0100 Subject: [PATCH] fix(single-instance): Check if pointer is null fixes #2405 --- .changes/single-instance-nullpointer-deref.md | 6 ++++++ plugins/process/permissions/schemas/schema.json | 2 +- plugins/single-instance/src/platform_impl/windows.rs | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changes/single-instance-nullpointer-deref.md diff --git a/.changes/single-instance-nullpointer-deref.md b/.changes/single-instance-nullpointer-deref.md new file mode 100644 index 00000000..13e212b2 --- /dev/null +++ b/.changes/single-instance-nullpointer-deref.md @@ -0,0 +1,6 @@ +--- +single-instance: patch +single-instance-js: patch +--- + +Fixed an issue that caused `null pointer dereference occurred` errors on rust nightly. diff --git a/plugins/process/permissions/schemas/schema.json b/plugins/process/permissions/schemas/schema.json index 1243c7d3..95f67149 100644 --- a/plugins/process/permissions/schemas/schema.json +++ b/plugins/process/permissions/schemas/schema.json @@ -322,4 +322,4 @@ ] } } -} +} \ No newline at end of file diff --git a/plugins/single-instance/src/platform_impl/windows.rs b/plugins/single-instance/src/platform_impl/windows.rs index e99f405d..2f6992ee 100644 --- a/plugins/single-instance/src/platform_impl/windows.rs +++ b/plugins/single-instance/src/platform_impl/windows.rs @@ -118,6 +118,11 @@ unsafe extern "system" fn single_instance_window_proc( ) -> LRESULT { let data_ptr = GetWindowLongPtrW(hwnd, GWL_USERDATA) as *mut (AppHandle, Box>); + + if data_ptr.is_null() { + return DefWindowProcW(hwnd, msg, wparam, lparam); + } + let (app_handle, callback) = &mut *data_ptr; match msg {