Skip to content
Permalink
Browse files
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).
  • Loading branch information
bblough committed Dec 4, 2018
1 parent 2a7003d commit 4a1ab3629d74746af0b6c840eb917ff0cd44b7e9
Showing 2 changed files with 9 additions and 13 deletions.
@@ -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;
}

@@ -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;
}

0 comments on commit 4a1ab36

Please sign in to comment.