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 f9d2212cfec00451e87df6d6b532220e999d98b7
Author: Robert Lazarski <[email protected]>
AuthorDate: Sat Jan 10 08:54:23 2026 -1000

    Add prevention fix for soap_envelope leak (AXIS2C-1262)
    
    Move namespace validation before envelope creation in
    axiom_soap_builder_construct_node(). This prevents allocating the
    envelope if validation will fail, complementing the cleanup fix
    in axiom_soap_builder_free().
    
    Based on approach from original JIRA patch by Supun Kamburugamuva.
    
    Co-Authored-By: Claude Opus 4.5 <[email protected]>
---
 axiom/src/soap/soap_builder.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/axiom/src/soap/soap_builder.c b/axiom/src/soap/soap_builder.c
index e0f379e82..f46589595 100644
--- a/axiom/src/soap/soap_builder.c
+++ b/axiom/src/soap/soap_builder.c
@@ -422,6 +422,14 @@ axiom_soap_builder_construct_node(
             return AXIS2_FAILURE;
         }
 
+        /* Validate namespace BEFORE creating envelope to prevent memory leak 
if validation fails */
+        status = axiom_soap_builder_process_namespace_data(soap_builder, env, 
om_element_node);
+        if(status != AXIS2_SUCCESS)
+        {
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SOAP Envelope is having 
invalid namespace");
+            return status;
+        }
+
         /** create a null soap envelope struct */
         soap_builder->soap_envelope = axiom_soap_envelope_create_null(env);
         if(!soap_builder->soap_envelope)
@@ -433,13 +441,8 @@ axiom_soap_builder_construct_node(
         /** wrap this OM node in it */
         axiom_soap_envelope_set_base_node(soap_builder->soap_envelope, env, 
om_element_node);
         axiom_soap_envelope_set_builder(soap_builder->soap_envelope, env, 
soap_builder);
-        status = axiom_soap_builder_process_namespace_data(soap_builder, env, 
om_element_node);
-        if(status != AXIS2_SUCCESS)
-        {
-            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SOAP Envelope is having 
invalid namespace");
-        }
 
-        return status;
+        return AXIS2_SUCCESS;
     }
 
     /** a parent node exist , so not soap envelope. Can be either 
header/body/children of them */

Reply via email to