Ver código fonte

fix #262: closesocket if newSslCtx failed

ithewei 3 anos atrás
pai
commit
8ebd7cf059
1 arquivos alterados com 6 adições e 1 exclusões
  1. 6 1
      evpp/TcpClient.h

+ 6 - 1
evpp/TcpClient.h

@@ -85,7 +85,12 @@ public:
         if (tls) {
         if (tls) {
             channel->enableSSL();
             channel->enableSSL();
             if (tls_setting) {
             if (tls_setting) {
-                channel->newSslCtx(tls_setting);
+                int ret = channel->newSslCtx(tls_setting);
+                if (ret != 0) {
+                    hloge("new SSL_CTX failed: %d", ret);
+                    closesocket();
+                    return ret;
+                }
             }
             }
             if (!is_ipaddr(remote_host.c_str())) {
             if (!is_ipaddr(remote_host.c_str())) {
                 channel->setHostname(remote_host);
                 channel->setHostname(remote_host);