axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billblo...@apache.org
Subject svn commit: r1848123 - in /axis/axis2/c/core/trunk/src/core/transport/http/sender: http_client.c ssl/ssl_stream.c
Date Tue, 04 Dec 2018 04:11:29 GMT
Author: billblough
Date: Tue Dec  4 04:11:29 2018
New Revision: 1848123

URL: http://svn.apache.org/viewvc?rev=1848123&view=rev
Log:
Fix memory leak in ssl connection

The ssl stream is only freed if axis2_http_sender is used to initiate
the connection.  Direct use of axis2_http_client causes a memory leak
since the SSL stream is never properly freed.

This commit frees the stream in http_client, and adds safeguards to
axis2_ssl_stream_free to prevent issues if called again (such as from
http_sender).

Modified:
    axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c
    axis/axis2/c/core/trunk/src/core/transport/http/sender/ssl/ssl_stream.c

Modified: axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c?rev=1848123&r1=1848122&r2=1848123&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c (original)
+++ axis/axis2/c/core/trunk/src/core/transport/http/sender/http_client.c Tue Dec  4 04:11:29
2018
@@ -123,19 +123,9 @@ axis2_http_client_free(
     }
     if(-1 != http_client->sockfd)
     {
-#ifdef AXIS2_SSL_ENABLED
-		if(http_client->data_stream->stream_type == AXIS2_STREAM_SOCKET)
-		{
-            axutil_stream_free(http_client->data_stream, env);
-            http_client->data_stream = NULL;
-			axutil_network_handler_close_socket(env, http_client->sockfd);
-			/** ssl streams of type AXIS2_STREAM_BASIC  will be handled by SSL_shutdown(); */
-		}
-#else
         axutil_stream_free(http_client->data_stream, env);
         http_client->data_stream = NULL;
 		axutil_network_handler_close_socket(env, http_client->sockfd);
-#endif
         http_client->sockfd = -1;
     }
 

Modified: axis/axis2/c/core/trunk/src/core/transport/http/sender/ssl/ssl_stream.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/core/transport/http/sender/ssl/ssl_stream.c?rev=1848123&r1=1848122&r2=1848123&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/core/transport/http/sender/ssl/ssl_stream.c (original)
+++ axis/axis2/c/core/trunk/src/core/transport/http/sender/ssl/ssl_stream.c Tue Dec  4 04:11:29
2018
@@ -119,9 +119,15 @@ axis2_ssl_stream_free(
 {
     ssl_stream_impl_t *stream_impl = NULL;
     axutil_stream_t* stream = (axutil_stream_t*)streamv;
-    stream_impl = AXIS2_INTF_TO_IMPL(stream);
-    axis2_ssl_utils_cleanup_ssl(env, stream_impl->ctx, stream_impl->ssl);
-    AXIS2_FREE(env->allocator, stream_impl);
+    if (stream)
+    {
+        stream_impl = AXIS2_INTF_TO_IMPL(stream);
+        if (stream_impl)
+        {
+            axis2_ssl_utils_cleanup_ssl(env, stream_impl->ctx, stream_impl->ssl);
+            AXIS2_FREE(env->allocator, stream_impl);
+        }
+    }
 
     return;
 }



Mime
View raw message