From d364e4914927b54baf0450459e3a156eb8632afd Mon Sep 17 00:00:00 2001
From: Gijs Peskens <gijs@peskens.net>
Date: Mon, 13 Feb 2023 15:55:13 +0100
Subject: [PATCH] Fix #142

---
 tools/ristsender.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/ristsender.c b/tools/ristsender.c
index 8ff1d3d0..6f059822 100644
--- a/tools/ristsender.c
+++ b/tools/ristsender.c
@@ -920,12 +920,13 @@ next:
 			rist_log(&logging_settings, RIST_LOG_ERROR, "Could not start rist receiver\n");
 			goto shutdown;
 		}
-		if (callback_object[i].receiver_ctx && pthread_create(&thread_main_loop[i+1], NULL, input_loop, (void *)callback_object) != 0)
+		if (callback_object[i].receiver_ctx && pthread_create(&thread_main_loop[i+1], NULL, input_loop, (void *)&callback_object[i]) != 0)
 		{
 			rist_log(&logging_settings, RIST_LOG_ERROR, "Could not start send rist receiver thread\n");
 			goto shutdown;
+		} else if (callback_object[i].receiver_ctx) {
+			thread_started[i+1] = true;
 		}
-		thread_started[i+1] = true;
 	}
 
 #ifdef USE_TUN
-- 
GitLab