axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Mitchell (JIRA)" <>
Subject [jira] Created: (AXIS2C-855) Generated stubs leak memory associated with string/array properties
Date Thu, 27 Dec 2007 19:56:43 GMT
Generated stubs leak memory associated with string/array properties

                 Key: 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_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:
For additional commands, e-mail:

View raw message