diff --git a/client/common/file.c b/client/common/file.c index 4c9eda34d..e74a9255a 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -716,6 +716,9 @@ static BOOL freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, if (targetValue) { + if ((uintptr_t)(*targetValue) != UINTPTR_MAX) + free(*targetValue); + *targetValue = _strdup(value); if (!(*targetValue)) return FALSE; diff --git a/libfreerdp/utils/signal.c b/libfreerdp/utils/signal.c index 346cd9855..cefe975df 100644 --- a/libfreerdp/utils/signal.c +++ b/libfreerdp/utils/signal.c @@ -195,6 +195,35 @@ static BOOL register_handlers(const int* signals, size_t count, void (*handler)( return TRUE; } +static void unregister_handlers(const int* signals, size_t count) +{ + WINPR_ASSERT(signals || (count == 0)); + + sigset_t orig_set = { 0 }; + struct sigaction saction = { 0 }; + + pthread_sigmask(SIG_BLOCK, &(saction.sa_mask), &orig_set); + + sigfillset(&(saction.sa_mask)); + sigdelset(&(saction.sa_mask), SIGCONT); + + saction.sa_handler = SIG_IGN; + saction.sa_flags = 0; + + for (size_t x = 0; x < count; x++) + { + sigaction(signals[x], &saction, NULL); + } + + pthread_sigmask(SIG_SETMASK, &orig_set, NULL); +} + +static void unregister_all_handlers(void) +{ + unregister_handlers(fatal_signals, ARRAYSIZE(fatal_signals)); + unregister_handlers(term_signals, ARRAYSIZE(term_signals)); +} + int freerdp_handle_signals(void) { int rc = -1; @@ -203,6 +232,7 @@ int freerdp_handle_signals(void) WLog_DBG(TAG, "Registering signal hook..."); + (void)atexit(unregister_all_handlers); if (!register_handlers(fatal_signals, ARRAYSIZE(fatal_signals), fatal_handler)) goto fail; if (!register_handlers(term_signals, ARRAYSIZE(term_signals), term_handler)) diff --git a/winpr/libwinpr/utils/wlog/wlog.c b/winpr/libwinpr/utils/wlog/wlog.c index ef4482217..e70fd22f7 100644 --- a/winpr/libwinpr/utils/wlog/wlog.c +++ b/winpr/libwinpr/utils/wlog/wlog.c @@ -74,10 +74,6 @@ static BOOL WLog_ParseFilter(wLog* root, wLogFilter* filter, LPCSTR name); static BOOL WLog_ParseFilters(wLog* root); static wLog* WLog_Get_int(wLog* root, LPCSTR name); -#if !defined(_WIN32) -static void WLog_Uninit_(void) __attribute__((destructor)); -#endif - static void WLog_Uninit_(void) { wLog* child = NULL;