Skip to content

Commit bfc7f67

Browse files
committed
libobs: Disallow overwriting the crash handler
Setting a new crash handler overwrites the existing one. This is not desirable.
1 parent a900281 commit bfc7f67

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docs/sphinx/reference-libobs-util-base.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Logging Functions
5555
.. function:: void base_set_crash_handler(void (*handler)(const char *, va_list, void *), void *param)
5656

5757
Sets the current crash handler.
58+
This may only be set once.
5859

5960
---------------------
6061

libobs/util/base.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ void base_set_log_handler(log_handler_t handler, void *param)
8383

8484
void base_set_crash_handler(void (*handler)(const char *, va_list, void *), void *param)
8585
{
86+
static bool non_default_handler_set = false;
87+
88+
if (non_default_handler_set) {
89+
blog(LOG_ERROR, "Tried to set a crash handler when one already exists. "
90+
"This is unsupported.");
91+
return;
92+
}
93+
94+
non_default_handler_set = true;
8695
crash_param = param;
8796
crash_handler = handler;
8897
}

0 commit comments

Comments
 (0)