From 18e1da54bdabe28bad74cf073b829ead075e8778 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 26 Sep 2024 16:21:32 +0200 Subject: [PATCH] module-rt: first join and then free memory First join the thread and then free the memory or else we might free the memory while the thread is starting up and we crash. --- src/modules/module-rt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/module-rt.c b/src/modules/module-rt.c index 3c1123aba..af22e624a 100644 --- a/src/modules/module-rt.c +++ b/src/modules/module-rt.c @@ -747,6 +747,9 @@ static int impl_join(void *object, struct spa_thread *thread, void **retval) struct impl *impl = object; pthread_t pt = (pthread_t)thread; struct thread *thr; + int res; + + res = pthread_join(pt, retval); pthread_mutex_lock(&impl->lock); if ((thr = find_thread_by_pt(impl, pt)) != NULL) { @@ -755,7 +758,7 @@ static int impl_join(void *object, struct spa_thread *thread, void **retval) } pthread_mutex_unlock(&impl->lock); - return pthread_join(pt, retval); + return res; }