]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[libesl] Coverity 1589045 Check of thread-shared field evades lock acquisition
authorAndrey Volk <andywolk@gmail.com>
Fri, 31 Jan 2025 16:05:04 +0000 (19:05 +0300)
committerAndrey Volk <andywolk@gmail.com>
Mon, 3 Feb 2025 23:18:47 +0000 (02:18 +0300)
libs/esl/src/esl.c

index f39bda83b1513e54e64922a992fa6ed1149d16bf..6f085e26dba58674902116973eb24910b360e2cb 100644 (file)
@@ -1167,13 +1167,6 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
        esl_event_safe_destroy(&handle->last_ievent);
        esl_event_safe_destroy(&handle->info_event);
 
-       if (mutex) {
-               esl_mutex_unlock(mutex);
-               esl_mutex_lock(mutex);
-               esl_mutex_unlock(mutex);
-               esl_mutex_destroy(&mutex);
-       }
-       
        if (handle->packet_buf) {
                esl_buffer_destroy(&handle->packet_buf);
        }
@@ -1181,6 +1174,13 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
        memset(handle, 0, sizeof(*handle));
        handle->destroyed = 1;
 
+       if (mutex) {
+               esl_mutex_unlock(mutex);
+               esl_mutex_lock(mutex);
+               esl_mutex_unlock(mutex);
+               esl_mutex_destroy(&mutex);
+       }
+
        return status;
 }