I'd be willing to give it a try, but right now I know nothing about how code 
generation works - turn around time for a fix may not be great.  Any doc or 
info that would serve as a starting point would really help... nothing should 
be considered too basic, I don't even know where the code generation template 
can be found.

Thanks,
Steve

----- Original Message ----- 
  From: Samisa Abeysinghe 
  To: Apache AXIS C Developers List 
  Sent: Tuesday, July 06, 2010 7:23 PM
  Subject: Re: memory leak in generated code


  This needs to be fixed in the code generation template so that the fix works 
right for all generated code.


  Is it possible for you to provide a patch for that?



  Samisa...


  On Sun, Jun 27, 2010 at 10:32 PM, Steve Leland <[email protected]> wrote:

    Hi,

    I am running on Windows Server 2008 R2, and using a build I made yesterday 
(svn 957643) I generated code from our wsdl and ran it - it has a leak that was 
also present in the 1.6.0 release.

    Given this in the wsdl file:

        <s:complexType name="CalendarEvent">
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="StartTime" 
type="s:dateTime" />
            <s:element minOccurs="1" maxOccurs="1" name="EndTime" 
type="s:dateTime" />
            <s:element minOccurs="1" maxOccurs="1" name="BusyType" 
type="tns:LegacyFreeBusyType" />
            <s:element minOccurs="0" maxOccurs="1" name="CalendarEventDetails" 
type="tns:CalendarEventDetails" />
          </s:sequence>
        </s:complexType>

    the following code is generated:

                     if (!_CalendarEvent->is_valid_StartTime)
                     {


                              AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil 
value found in non-nillable property StartTime");
                              return NULL;

                     }
                     else
                     {
                       start_input_str = 
(axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                   (4 + axutil_strlen(p_prefix) +
                                    axutil_strlen("StartTime")));

                                   /* axutil_strlen("<:>") + 1 = 4 */
                       end_input_str = 
(axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                   (5 + axutil_strlen(p_prefix) + 
axutil_strlen("StartTime")));
                                    /* axutil_strlen("</:>") + 1 = 5 */






                       /*
                        * parsing StartTime element
                        */



                              sprintf(start_input_str, "<%s%sStartTime>",
                                   p_prefix?p_prefix:"",
                                   (p_prefix && axutil_strcmp(p_prefix, 
""))?":":"");

                          start_input_str_len = axutil_strlen(start_input_str);
                          sprintf(end_input_str, "</%s%sStartTime>",
                                   p_prefix?p_prefix:"",
                                   (p_prefix && axutil_strcmp(p_prefix, 
""))?":":"");
                          end_input_str_len = axutil_strlen(end_input_str);

                            text_value_1 = 
axutil_date_time_serialize_date_time(_CalendarEvent->property_StartTime, 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);

                   -> fix goes here <-
                       AXIS2_FREE(env->allocator,start_input_str);
                       AXIS2_FREE(env->allocator,end_input_str);
                   }

    The leak is "text_value_1" not being freed.  To fix the leak, add
    AXIS2_FREE(env->allocator,text_value_1);
    where indicated.

    Regards,
    Steve





    ---------------------------------------------------------------------
    To unsubscribe, e-mail: [email protected]
    For additional commands, e-mail: [email protected]


  Samisa Abeysinghe
  VP Engineering
  WSO2 Inc. 
  http://wso2.com
  http://wso2.org


Reply via email to