From e57f29f8f65c83063fd8f63c88f88830fc269bd6 Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Mon, 15 Dec 2014 00:18:45 +0100 Subject: [PATCH] packet.c: fix possible NULL pointer de-reference within listen_state Fixes VS2012 code analysis warning C6011: dereferencing NULL pointer 'listen_state->channel'. libssh2 packet.c 221 --- src/packet.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/packet.c b/src/packet.c index 74e26d7..789c803 100644 --- a/src/packet.c +++ b/src/packet.c @@ -218,9 +218,11 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data, } /* Link the channel into the end of the queue list */ - _libssh2_list_add(&listn->queue, - &listen_state->channel->node); - listn->queue_size++; + if (listen_state->channel) { + _libssh2_list_add(&listn->queue, + &listen_state->channel->node); + listn->queue_size++; + } listen_state->state = libssh2_NB_state_idle; return 0;