File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ static gpointer _gattlib_connected_device_thread(gpointer data) {
5151 gattlib_context_t * conn_context = connection -> context ;
5252 const gchar * device_mac_address = org_bluez_device1_get_address (conn_context -> device );
5353
54+ // Mutex to ensure the device is valid and not freed during its use
55+ g_mutex_lock (& connection -> device_mutex );
56+ // Mutex to ensure the handler is valid
5457 g_rec_mutex_lock (& connection -> on_connection .mutex );
5558
5659 if (!gattlib_has_valid_handler (& connection -> on_connection )) {
@@ -63,6 +66,7 @@ static gpointer _gattlib_connected_device_thread(gpointer data) {
6366
6467EXIT :
6568 g_rec_mutex_unlock (& connection -> on_connection .mutex );
69+ g_mutex_unlock (& connection -> device_mutex );
6670 return NULL ;
6771}
6872
You can’t perform that action at this time.
0 commit comments