mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-29 13:01:13 +03:00
examples: Avoid accessing list before acquiring lock
Thanks coverity CID 1526592 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
@ -343,10 +343,11 @@ static void delete_item(ssh_channel channel)
|
|||||||
|
|
||||||
static node_t *search_item(ssh_channel channel)
|
static node_t *search_item(ssh_channel channel)
|
||||||
{
|
{
|
||||||
node_t *current = node;
|
node_t *current = NULL;
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex);
|
pthread_mutex_lock(&mutex);
|
||||||
|
|
||||||
|
current = node;
|
||||||
while (current != NULL) {
|
while (current != NULL) {
|
||||||
if (current->channel == channel) {
|
if (current->channel == channel) {
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
|
Reference in New Issue
Block a user