diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2013-06-17 13:04:27 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-06-17 13:04:27 +0200 |
commit | ee47cab5483bce22efc8415effb9e122963ee668 (patch) | |
tree | 392c55eaf5d5953ad3660116007d1ab3ad01d551 /src/packet.c | |
parent | a65029da5d62138002328eec0eb1be991c1d5431 (diff) | |
download | libssh-ee47cab5483bce22efc8415effb9e122963ee668.tar.gz libssh-ee47cab5483bce22efc8415effb9e122963ee668.tar.xz libssh-ee47cab5483bce22efc8415effb9e122963ee668.zip |
packet: Fix a possible segfault.
Diffstat (limited to 'src/packet.c')
-rw-r--r-- | src/packet.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/packet.c b/src/packet.c index 2256f113..d4f4d835 100644 --- a/src/packet.c +++ b/src/packet.c @@ -305,10 +305,12 @@ void ssh_packet_register_socket_callback(ssh_session session, ssh_socket s){ * @brief sets the callbacks for the packet layer */ void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks){ - if(session->packet_callbacks == NULL){ - session->packet_callbacks = ssh_list_new(); - } - ssh_list_append(session->packet_callbacks, callbacks); + if(session->packet_callbacks == NULL){ + session->packet_callbacks = ssh_list_new(); + } + if (session->packet_callbacks != NULL) { + ssh_list_append(session->packet_callbacks, callbacks); + } } /** @internal @@ -526,6 +528,3 @@ int packet_send(ssh_session session) { #endif return packet_send2(session); } - - -/* vim: set ts=2 sw=2 et cindent: */ |