mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-09 06:46:36 +00:00
posix: avoid use-after-free in signal handler
This commit is contained in:
parent
34c6d5e068
commit
783a8debb9
@ -51,6 +51,12 @@ static void signal_callback(void * arg){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void * signal_thread(void *arg) {
|
static void * signal_thread(void *arg) {
|
||||||
|
// prepare registration
|
||||||
|
btstack_context_callback_registration_t registration;
|
||||||
|
memset(®istration, 0, sizeof(btstack_context_callback_registration_t));
|
||||||
|
registration.callback = &signal_callback;
|
||||||
|
registration.context = arg;
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
// wait for signal
|
// wait for signal
|
||||||
sigset_t sigset;
|
sigset_t sigset;
|
||||||
@ -60,10 +66,6 @@ static void * signal_thread(void *arg) {
|
|||||||
(void) sigwait(&sigset, &sig);
|
(void) sigwait(&sigset, &sig);
|
||||||
|
|
||||||
// execute callback on main thread
|
// execute callback on main thread
|
||||||
btstack_context_callback_registration_t registration;
|
|
||||||
memset(®istration, 0, sizeof(btstack_context_callback_registration_t));
|
|
||||||
registration.callback = &signal_callback;
|
|
||||||
registration.context = arg;
|
|
||||||
btstack_run_loop_execute_on_main_thread(®istration);
|
btstack_run_loop_execute_on_main_thread(®istration);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user