From 6383653dbf425d678fc55d70cff37a8fd56102aa Mon Sep 17 00:00:00 2001 From: Zach Vorhies Date: Sat, 24 Oct 2026 18:53:11 -0700 Subject: [PATCH] Check os_event_init results in module load and ExecuteOnBrowser Since obs-rust/obs-studio#2163 a failed os_event_init() leaves the event NULL. obs_module_load() now fails cleanly if either startup event cannot be created, and ExecuteOnBrowser() returns without queueing a task that would signal a missing event. Fixes #4 --- obs-browser-plugin.cpp | 10 ++++++++-- obs-browser-source.cpp | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/obs-browser-plugin.cpp b/obs-browser-plugin.cpp index 6ced773..1d4562e 100644 --- a/obs-browser-plugin.cpp +++ b/obs-browser-plugin.cpp @@ -904,8 +904,14 @@ bool obs_module_load(void) qRegisterMetaType("MessageTask"); #endif - os_event_init(&cef_started_event, OS_EVENT_TYPE_MANUAL); - os_event_init(&cef_initialized_event, OS_EVENT_TYPE_MANUAL); + if (os_event_init(&cef_started_event, OS_EVENT_TYPE_MANUAL) != 0 || + os_event_init(&cef_initialized_event, OS_EVENT_TYPE_MANUAL) != 0) { + blog(LOG_ERROR, "[obs-browser]: Failed to create CEF startup events"); + os_event_destroy(cef_started_event); + cef_started_event = nullptr; + cef_initialized_event = nullptr; + return false; + } #if defined(_WIN32) && CHROME_VERSION_BUILD < 5615 /* CefEnableHighDPISupport doesn't do anything on OS other than Windows. Would also crash macOS at this point as CEF is not directly linked */ diff --git a/obs-browser-source.cpp b/obs-browser-source.cpp index efed81a..2871aec 100644 --- a/obs-browser-source.cpp +++ b/obs-browser-source.cpp @@ -169,7 +169,10 @@ void BrowserSource::ExecuteOnBrowser(BrowserFunc func, bool async) } #endif os_event_t *finishedEvent; - os_event_init(&finishedEvent, OS_EVENT_TYPE_AUTO); + if (os_event_init(&finishedEvent, OS_EVENT_TYPE_AUTO) != 0) { + blog(LOG_ERROR, "[obs-browser]: Failed to create browser task event"); + return; + } bool success = QueueCEFTask([&]() { if (!!cefBrowser) { func(cefBrowser);