You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by ro...@apache.org on 2026/01/10 19:48:05 UTC
(axis-axis2-c-core) 02/02: Fix memory leaks when server returns error (AXIS2C-1214)
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 74ca7e9c34c63f8072fd996a82accff5ca8f093b
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Sat Jan 10 09:20:11 2026 -1000
Fix memory leaks when server returns error (AXIS2C-1214)
Fix engine and fault message context memory leaks in error handling paths:
1. svr_callback.c: axis2_svr_callback_handle_result() was not freeing the
engine after use. axis2_svr_callback_handle_fault() was not freeing
either the engine or the fault_ctx message context.
2. http_transport_utils.c: In axis2_http_transport_utils_process_request(),
when processing fails and a SOAP fault is generated, both engine and
fault_ctx were created but never freed.
3. apache2_worker.c: Same issue in axis2_apache2_worker_process_request()
error handling path - engine and fault_ctx were not freed.
These leaks occurred whenever the server returned an error response,
as reported in the original Jira issue.
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
src/core/receivers/svr_callback.c | 16 ++++++++++++++--
src/core/transport/http/server/apache2/apache2_worker.c | 5 +++++
src/core/transport/http/util/http_transport_utils.c | 5 +++++
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/core/receivers/svr_callback.c b/src/core/receivers/svr_callback.c
index 2fe68b1b6..803194e4b 100644
--- a/src/core/receivers/svr_callback.c
+++ b/src/core/receivers/svr_callback.c
@@ -80,7 +80,11 @@ axis2_svr_callback_handle_result(
{
return AXIS2_FAILURE;
}
- return axis2_engine_send(engine, env, msg_ctx);
+ {
+ axis2_status_t status = axis2_engine_send(engine, env, msg_ctx);
+ axis2_engine_free(engine, env);
+ return status;
+ }
}
AXIS2_EXPORT axis2_status_t AXIS2_CALL
@@ -108,5 +112,13 @@ axis2_svr_callback_handle_fault(
}
fault_ctx = axis2_engine_create_fault_msg_ctx(engine, env, msg_ctx, NULL, NULL);
- return axis2_engine_send_fault(engine, env, fault_ctx);
+ {
+ axis2_status_t status = axis2_engine_send_fault(engine, env, fault_ctx);
+ if(fault_ctx)
+ {
+ axis2_msg_ctx_free(fault_ctx, env);
+ }
+ axis2_engine_free(engine, env);
+ return status;
+ }
}
diff --git a/src/core/transport/http/server/apache2/apache2_worker.c b/src/core/transport/http/server/apache2/apache2_worker.c
index 94e4adc8b..eafc4b752 100644
--- a/src/core/transport/http/server/apache2/apache2_worker.c
+++ b/src/core/transport/http/server/apache2/apache2_worker.c
@@ -945,6 +945,11 @@ axis2_apache2_worker_process_request(
axutil_error_get_message
(env->error));
axis2_engine_send_fault(engine, env, fault_ctx);
+ if(fault_ctx)
+ {
+ axis2_msg_ctx_free(fault_ctx, env);
+ }
+ axis2_engine_free(engine, env);
if (out_stream)
{
body_string = axutil_stream_get_buffer(out_stream, env);
diff --git a/src/core/transport/http/util/http_transport_utils.c b/src/core/transport/http/util/http_transport_utils.c
index db2bf689f..670f54a31 100644
--- a/src/core/transport/http/util/http_transport_utils.c
+++ b/src/core/transport/http/util/http_transport_utils.c
@@ -3219,6 +3219,11 @@ axis2_http_transport_utils_process_request(
fault_code, axutil_error_get_message(env->error));
axis2_engine_send_fault(engine, env, fault_ctx);
+ if(fault_ctx)
+ {
+ axis2_msg_ctx_free(fault_ctx, env);
+ }
+ axis2_engine_free(engine, env);
if (out_stream)
{
response->response_data = axutil_stream_get_buffer(out_stream, env);