From 13b37050984b708eaa4019f82d177331db92ea3f Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 29 Apr 2022 09:30:54 +0200 Subject: [PATCH] RTSP cap.: fixed init crash Fixed a crash when init fails and done function is called - check if threads that are to be destroyed were actually created. --- src/video_capture/rtsp.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/video_capture/rtsp.cpp b/src/video_capture/rtsp.cpp index 44fda2376..3e67e20c9 100644 --- a/src/video_capture/rtsp.cpp +++ b/src/video_capture/rtsp.cpp @@ -1027,8 +1027,12 @@ vidcap_rtsp_done(void *state) { pthread_cond_signal(&s->keepalive_cv); pthread_mutex_unlock(&s->lock); - pthread_join(s->vrtsp_state.vrtsp_thread_id, NULL); - pthread_join(s->keep_alive_rtsp_thread_id, NULL); + if (s->vrtsp_state.vrtsp_thread_id) { + pthread_join(s->vrtsp_state.vrtsp_thread_id, NULL); + } + if (s->keep_alive_rtsp_thread_id) { + pthread_join(s->keep_alive_rtsp_thread_id, NULL); + } if(s->vrtsp_state.sd) decompress_done(s->vrtsp_state.sd);