From 675c20f08f32ca5ec06297108bdf30147d6e2cd9 Mon Sep 17 00:00:00 2001
From: akallabeth <akallabeth@posteo.net>
Date: Tue, 13 Jan 2026 09:39:33 +0100
Subject: [PATCH] [channels,serial] explicitly lock serial->IrpThreads

---
 channels/serial/client/serial_main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Index: FreeRDP-3.10.3/channels/serial/client/serial_main.c
===================================================================
--- FreeRDP-3.10.3.orig/channels/serial/client/serial_main.c
+++ FreeRDP-3.10.3/channels/serial/client/serial_main.c
@@ -614,7 +614,10 @@ static void create_irp_thread(SERIAL_DEV
 	 * observed with FreeRDP).
 	 */
 	key = irp->CompletionId + 1ull;
+
+	ListDictionary_Lock(serial->IrpThreads);
 	previousIrpThread = ListDictionary_GetItemValue(serial->IrpThreads, (void*)key);
+	ListDictionary_Unlock(serial->IrpThreads);
 
 	if (previousIrpThread)
 	{
@@ -726,7 +729,10 @@ static DWORD WINAPI serial_thread_func(L
 			create_irp_thread(serial, irp);
 	}
 
+	ListDictionary_Lock(serial->IrpThreads);
 	ListDictionary_Clear(serial->IrpThreads);
+	ListDictionary_Unlock(serial->IrpThreads);
+
 	if (error && serial->rdpcontext)
 		setChannelError(serial->rdpcontext, error, "serial_thread_func reported an error");
 
