mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-05-18 13:33:27 -04:00
libobs: Disallow overwriting the crash handler
Setting a new crash handler overwrites the existing one. This is not desirable.
This commit is contained in:
committed by
Ryan Foster
parent
1b41b44b50
commit
77fb5b4bc7
@@ -55,6 +55,7 @@ Logging Functions
|
||||
.. function:: void base_set_crash_handler(void (*handler)(const char *, va_list, void *), void *param)
|
||||
|
||||
Sets the current crash handler.
|
||||
This may only be set once.
|
||||
|
||||
---------------------
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "c99defs.h"
|
||||
#include "base.h"
|
||||
#include "threading.h"
|
||||
|
||||
static int crashing = 0;
|
||||
static void *log_param = NULL;
|
||||
@@ -83,6 +84,13 @@ void base_set_log_handler(log_handler_t handler, void *param)
|
||||
|
||||
void base_set_crash_handler(void (*handler)(const char *, va_list, void *), void *param)
|
||||
{
|
||||
static bool non_default_handler_set = false;
|
||||
|
||||
if (os_atomic_exchange_bool(&non_default_handler_set, true)) {
|
||||
blog(LOG_WARNING, "Tried to set a crash handler when one already exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
crash_param = param;
|
||||
crash_handler = handler;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user