check if con != NULL before using it
authorNils Larsch <nils@openssl.org>
Sat, 18 Mar 2006 14:24:02 +0000 (14:24 +0000)
committerNils Larsch <nils@openssl.org>
Sat, 18 Mar 2006 14:24:02 +0000 (14:24 +0000)
apps/s_client.c
apps/s_server.c

index fed012230a73f14de435bf8462aaa2aced1ec818..251da63ed542873e1f8db2f792dd0c13cc816de0 100644 (file)
@@ -1237,8 +1237,12 @@ shut:
        SHUTDOWN(SSL_get_fd(con));
        ret=0;
 end:
-       if(prexit) print_stuff(bio_c_out,con,1);
-       if (con != NULL) SSL_free(con);
+       if (con != NULL)
+               {
+               if (prexit != 0)
+                       print_stuff(bio_c_out,con,1);
+               SSL_free(con);
+               }
        if (ctx != NULL) SSL_CTX_free(ctx);
        if (cert)
                X509_free(cert);
index 72d0b6cd4b7b038b88a68e04cc5576d99535e17e..903f1c47fc913f5c7e6ff817cff54aa6d283b5b5 100644 (file)
@@ -1813,13 +1813,16 @@ again:
                        }
                }
 err:
-       BIO_printf(bio_s_out,"shutting down SSL\n");
+       if (con != NULL)
+               {
+               BIO_printf(bio_s_out,"shutting down SSL\n");
 #if 1
-       SSL_set_shutdown(con,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
+               SSL_set_shutdown(con,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
 #else
-       SSL_shutdown(con);
+               SSL_shutdown(con);
 #endif
-       if (con != NULL) SSL_free(con);
+               SSL_free(con);
+               }
        BIO_printf(bio_s_out,"CONNECTION CLOSED\n");
        if (buf != NULL)
                {