From 2a5819c9965b6fa296f8a2ace7aaf70156ee9f90 Mon Sep 17 00:00:00 2001 From: Andreas Kotes Date: Tue, 15 Apr 2014 12:13:13 +0200 Subject: handle SSL I/O errors more gracefully, avoid double free --- vchat-protocol.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vchat-protocol.c b/vchat-protocol.c index b50f511..e676b28 100755 --- a/vchat-protocol.c +++ b/vchat-protocol.c @@ -166,8 +166,11 @@ vcconnect (char *server, char *port) } /* upgrade our plain BIO to ssl */ - if( vc_connect_ssl( &server_conn, &vc_store ) ) + if( vc_connect_ssl( &server_conn, &vc_store ) ) { BIO_free_all( server_conn ); + server_conn = NULL; + errno = EIO; + } } if( !server_conn ) { @@ -188,7 +191,8 @@ vcconnect (char *server, char *port) /* disconnect from server */ void vcdisconnect () { - BIO_free_all( server_conn ); + if (server_conn) + BIO_free_all( server_conn ); serverfd = -1; } -- cgit v1.2.3