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 "Bill Mitchell (JIRA)" <ji...@apache.org> on 2007/12/30 19:39:43 UTC

[jira] Commented: (AXIS2C-855) Generated stubs leak memory associated with string/array properties

    [ https://issues.apache.org/jira/browse/AXIS2C-855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12555011 ] 

Bill Mitchell commented on AXIS2C-855:
--------------------------------------

I regenerated with a new build and verified that the reset code is now correct in all of them.  Thanks.  

> Generated stubs leak memory associated with string/array properties
> -------------------------------------------------------------------
>
>                 Key: AXIS2C-855
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-855
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: code generation
>    Affects Versions: Current (Nightly)
>         Environment: Windows XP, Visual Studio 2005, guththila parser, libcurl
>            Reporter: Bill Mitchell
>
> The generated adb_<type>_free methods leak memory associated with string or array properties, i.e., any property with associated memory.  The free routine correctly calls the reset routine to actually free the memory.  But the reset routine has an incorrectly written guard to verify its passed pointer, such that it always returns without freeing anything.  
> Here is a sample of the generated reset routine for a constraint property that is a string.  
>            axis2_status_t AXIS2_CALL
>            adb_conditionInstance_type0_reset_constraint(
>                    adb_conditionInstance_type0_t* _conditionInstance_type0,
>                    const axutil_env_t *env)
>            {
>                int i = 0;
>                int count = 0;
>                void *element = NULL;
>                AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
>                AXIS2_PARAM_CHECK(env->error, _conditionInstance_type0, AXIS2_FAILURE);
>                if(NULL != _conditionInstance_type0)
>                {
>                    return AXIS2_FAILURE;
>                }
>                 if(_conditionInstance_type0->property_constraint != NULL)
>                 {
>                         AXIS2_FREE(env-> allocator, _conditionInstance_type0->property_constraint);
>                      _conditionInstance_type0->property_constraint = NULL;
>                 }
>                 _conditionInstance_type0->is_valid_constraint = AXIS2_FALSE;
>                return AXIS2_SUCCESS;
>            }
> As you can see, after using AXIS2_PARAM_CHECK to return an error if the passed _conditionInstance_type0 pointer is zero, the generated code then returns an error if the pointer is nonzero.  Although one could simply fix the != comparison to be ==, the second test is redundant thanks to the AXIS2_PARAM_CHECK and could best be removed entirely.  
> This error is present in all of the adb_<type>_reset routines, but causes a memory leak only for types represented by allocated memory.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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