From bbb6781ca170d69744a2c9a0ef0d10434139be63 Mon Sep 17 00:00:00 2001 From: nick black Date: Tue, 14 Jan 2025 13:59:08 -0500 Subject: [PATCH] unixsig: check for NULL altstack in drop_signals() #2842 --- src/lib/unixsig.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/unixsig.c b/src/lib/unixsig.c index 38326c1a8..b7d458a34 100644 --- a/src/lib/unixsig.c +++ b/src/lib/unixsig.c @@ -19,7 +19,9 @@ int unblock_signals(const sigset_t* old_blocked_signals){ int drop_signals(void* nc, void** altstack){ void* expected = nc; - *altstack = NULL; + if(!altstack){ + return 0; + } if(!atomic_compare_exchange_strong(&signal_nc, &expected, NULL)){ return -1; } @@ -100,6 +102,9 @@ int unblock_signals(const sigset_t* old_blocked_signals){ int drop_signals(void* nc, void** altstack){ int ret = -1; void* expected = nc; + if(!altstack){ // came in via signal handler + return 0; + } *altstack = NULL; pthread_mutex_lock(&lock); if(atomic_compare_exchange_strong(&signal_nc, &expected, nc)){