axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From axis-c-...@ws.apache.org
Subject [jira] Closed: (AXISCPP-186) The WSDL2WS generated class constructors needs to 'zero' all parameters
Date Tue, 05 Oct 2004 12:01:32 GMT
Message:

   The following issue has been closed.

   Resolver: Fred Preston
       Date: Tue, 5 Oct 2004 5:01 AM

Hi All,
Changed code in org.apache.axis.wsdl.wsdl2ws.cpp.literal.BeanParamWriter from
protected void writeConstructors() throws WrapperFault {
 try{
  writer.write("\n"+classname+"::"+classname+"()\n{\n");
  writer.write("\t/*do not allocate memory to any pointer members here\n\t because deserializer
will allocate memory anyway. */\n");
  for(int i = 0; i< attribs.length;i++){
   if (attribs[i].isArray()){
    writer.write("\t"+attribs[i].getParamName()+".m_Array = 0;\n");
    writer.write("\t"+attribs[i].getParamName()+".m_Size = 0;\n");
   }
   else if (!attribs[i].isSimpleType()){
    writer.write("\t"+attribs[i].getParamName()+"=0;\n");
   } else {
/* Needed for shared libraries */
    if ("xsd__string".equals(attribs[i].getTypeName()))
     writer.write("\t"+attribs[i].getParamName()+" = 0;\n");
    }
   }			

To:
protected void writeConstructors() throws WrapperFault {
 try{
  writer.write("\n"+classname+"::"+classname+"()\n{\n");
  writer.write("\t/*do not allocate memory to any pointer members here\n\t because deserializer
will allocate memory anyway. */\n");
  for(int i = 0; i< attribs.length;i++){
   if (attribs[i].isArray()){
    writer.write("\t"+attribs[i].getParamName()+".m_Array = 0;\n");
    writer.write("\t"+attribs[i].getParamName()+".m_Size = 0;\n");
   }
   else if (!attribs[i].isSimpleType()){
    writer.write("\t"+attribs[i].getParamName()+"=0;\n");
   } else {
/* Needed for shared libraries */
    writer.write("\tmemset( &" + attribs[i].getParamName() + ", 0, sizeof( " + attribs[i].getTypeName()
+ "));\n");
   }
  }			

The new code clears the variable.
---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/AXISCPP-186

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: AXISCPP-186
    Summary: The WSDL2WS generated class constructors needs to 'zero' all parameters
       Type: Bug

     Status: Closed
   Priority: Major
 Resolution: FIXED

    Project: Axis-C++
 Components: 
             WSDL generation

   Assignee: Fred Preston
   Reporter: Fred Preston

    Created: Tue, 5 Oct 2004 3:08 AM
    Updated: Tue, 5 Oct 2004 5:01 AM
Environment: n/a

Description:
Summary:
========
The WSDL2WS generated class constructors needs to 'zero' all parameters.

Problem:
========
Currently, the constructor only nulls the class variables that are pointers, i.e.
object.h
--------
ObjectBean* Bean;
ObjectBeanArrayType* BeanArray;
xsd__boolean Boolean;
xsd__base64Binary ByteArray;

object.c
--------
Object::Object()
{
/*do not allocate memory to any pointer members here
 because deserializer will allocate memory anyway. */
Bean=0;
BeanArray=0;
}

If the user does not properly setup the object before serialisation (i.e ByteArray), problems
can occur when the serialiser tries to serialise a bad pointer.

Solution:
=========
By adding additional code to the WSDL2WS code, the constructor can null non-pointer variables
as follows:-
object.c
--------
Object::Object()
{
/*do not allocate memory to any pointer members here
 because deserializer will allocate memory anyway. */
Bean=0;
BeanArray=0;
memset( &Boolean, 0, sizeof( xsd__boolean));
memset( &ByteArray, 0, sizeof( xsd__base64Binary));
}

Thus if the user tries to serialise an object without properly initialising it first, there
will not be any invalid pointers within the object.


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Mime
View raw message