You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Robert Lazarski (Jira)" <ji...@apache.org> on 2026/01/13 21:44:00 UTC

[jira] [Resolved] (AXIS2C-1529) wsdl2c generates skeleton code with memoryleak inside

     [ https://issues.apache.org/jira/browse/AXIS2C-1529?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Lazarski resolved AXIS2C-1529.
-------------------------------------
    Fix Version/s: 2.0.0
                       (was: 1.7.0)
       Resolution: Fixed

 The Java-based WSDL2C generator creates code that leaks memory when
    serializing base64Binary types. The axutil_base64_binary_get_encoded_binary()
    function allocates memory that was never freed after being written.
    
    This fix implements proper base64Binary handling in the native generator:
    
    - Map base64Binary to axutil_base64_binary_t* (not axiom_node_t*)
    - Free memory allocated by get_encoded_binary() after serialization
    - Use axutil_base64_binary_free() in generated free functions
    - Implement deserialize using axutil_base64_binary_create() and
      axutil_base64_binary_set_encoded_binary()
    - Sanitize WSDL filename-derived service names (handles hyphens)
    
    Also adds test suite with 7 tests validating the fix.


> wsdl2c generates skeleton code with memoryleak inside
> -----------------------------------------------------
>
>                 Key: AXIS2C-1529
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-1529
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: code generation
>    Affects Versions: 1.6.0
>         Environment: This bug can be reproduced on linux as well as on Win32.
> On Win32 the following environment is used
> - axis2c version 1.6.0
> - axis2 java version axis2-1.5.2 (axis2-1.5.3 on linux)
> - java full version "JRE 1.6.0 IBM Windows 32 build pwi3260sr8fp1-20100903_02 (SR8 FP1)"
>            Reporter: Christof Schmalenbach
>            Priority: Major
>             Fix For: 2.0.0
>
>         Attachments: MemLeak.java, adb_getServiceDataResponse.c, axis2cwsdl2cmembug.wsdl
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> One can reproduce the problem with the following steps:
> 1. Compile the following java class (only to generate a appropriate wsdl used in step 2)
> package memleak;
> public class MemLeak
> {
> 	public byte[] getServiceData(byte[] input)
> 	{
> 		byte[] output = new byte[10];
> 		return(output);
> 	}
> }
> 2. generate wsdl with the following command from the MemLeak class
> java2wsdl -o . -of axis2cwsdl2cmembug.wsdl -sn axis2cmemleak -cn memleak.MemLeak 
> 3. generate serverside code (skeletons) from the axis2cwsdl2cmembug.wsdl with the following command:
> wsdl2c -o .\c_axis2cwsdl2membug_skeleton -ss -uri axis2cwsdl2cmembug.wsdl
> Step 3. generates the following artefacts:
> ./axis2_skel_axis2cmemleak.c
> ./axis2_skel_axis2cmemleak.h
> ./axis2_svc_skel_axis2cmemleak.c
> ./src
> ./src./adb_getServiceData.c
> ./src./adb_getServiceData.h
> ./src./adb_getServiceDataResponse.c
> ./src./adb_getServiceDataResponse.h
> Especially .the generated code /src./adb_getServiceDataResponse.c contains a memory leak in the function
> adb_getServiceDataResponse_serialize
> within every webservice request cycle.
> Following code is generated in this function:
>                           text_value_1 =axutil_base64_binary_get_encoded_binary(_getServiceDataResponse->property_return, env);
>                            
>                            axutil_stream_write(stream, env, start_input_str, start_input_str_len);
>                            
>                            axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1));
>                            
>                            axutil_stream_write(stream, env, end_input_str, end_input_str_len);
>                            
>                      
>                      AXIS2_FREE(env->allocator,start_input_str);
>                      AXIS2_FREE(env->allocator,end_input_str);
> memory for start_input_str and for end_input_str are released , BUT not the memory allocated in axutil_base64_binary_get_encoded_binary for the pointer text_value_1.
> An AXIS2_FREE(env->allocator,text_value_1.); is missed.
> This AXIS2_FREE can be included in the generated code, solving the memory leak without destabilizing the service.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: c-dev-help@axis.apache.org