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


The following commit(s) were added to refs/heads/master by this push:
     new 42ff1d100 Fix soap_envelope memory leak in error path (AXIS2C-1262)
42ff1d100 is described below

commit 42ff1d100d42325ba1acadab1b5504d89e5f4324
Author: Robert Lazarski <[email protected]>
AuthorDate: Sat Jan 10 08:37:23 2026 -1000

    Fix soap_envelope memory leak in error path (AXIS2C-1262)
    
    When axiom_soap_builder_create() fails during SOAP version validation,
    the soap_envelope wrapper was allocated but never freed. This adds
    cleanup in axiom_soap_builder_free() to properly free the envelope.
    
    The fix breaks the circular reference (envelope->builder) before freeing
    and clears the envelope's node pointer since the stax_builder owns the
    underlying XML tree.
    
    Co-Authored-By: Claude Opus 4.5 <[email protected]>
---
 axiom/src/soap/soap_builder.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/axiom/src/soap/soap_builder.c b/axiom/src/soap/soap_builder.c
index a2e8b23fc..e0f379e82 100644
--- a/axiom/src/soap/soap_builder.c
+++ b/axiom/src/soap/soap_builder.c
@@ -189,6 +189,18 @@ axiom_soap_builder_free(
         }
     }
 
+    /* Free the soap_envelope wrapper if it exists (AXIS2C-1262).
+     * The envelope has a back-pointer to us, so we must break the circular 
reference
+     * before freeing. Also clear the envelope's node pointer since the 
stax_builder
+     * owns and will free the underlying XML tree. */
+    if(soap_builder->soap_envelope)
+    {
+        axiom_soap_envelope_set_builder(soap_builder->soap_envelope, env, 
NULL);
+        axiom_soap_envelope_set_base_node(soap_builder->soap_envelope, env, 
NULL);
+        axiom_soap_envelope_free(soap_builder->soap_envelope, env);
+        soap_builder->soap_envelope = NULL;
+    }
+
     if(soap_builder->om_builder)
     {
         axiom_stax_builder_free(soap_builder->om_builder, env);

Reply via email to