ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whitl...@apache.org
Subject cvs commit: ws-axis/c/tests/auto_build/testcases/output IHeaderBlockTest5.expected
Date Tue, 01 Mar 2005 15:02:04 GMT
whitlock    2005/03/01 07:02:04

  Modified:    c/src/soap ComplexElement.cpp
               c/tests/auto_build/testcases/client/cpp
                        IHeaderBlockTest5Client.cpp
               c/tests/auto_build/testcases/output
                        IHeaderBlockTest5.expected
  Log:
  AXISCPP-495 Fix IHeaderBlockTest5.
  Fix various SIGSEGV's and storage leaks in ComplexElement due to m_pachLocalName, m_pachPrefix
and m_pachURI
  Fix the IHeaderBlockTest5 so that a complex element without a local name isn't serialized.
It is valid to create one without a local name, but the local name must be set before it is
serialized.
  
  Revision  Changes    Path
  1.36      +35 -10    ws-axis/c/src/soap/ComplexElement.cpp
  
  Index: ComplexElement.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/ComplexElement.cpp,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ComplexElement.cpp	9 Feb 2005 11:30:53 -0000	1.35
  +++ ComplexElement.cpp	1 Mar 2005 15:02:04 -0000	1.36
  @@ -50,9 +50,9 @@
   
   ComplexElement::ComplexElement():m_pParent(NULL)
   {
  -    m_pachPrefix = '\0';
  -    m_pachLocalName = '\0';
  -    m_pachURI = '\0';
  +	m_pachPrefix = NULL;
  +    m_pachLocalName = NULL;
  +    m_pachURI = NULL;
   
       m_iNodeType= ELEMENT_NODE;
       iNoOfChildren = 0;
  @@ -112,9 +112,18 @@
   
   ComplexElement::~ComplexElement()
   {
  -    delete [] m_pachPrefix;
  -    delete [] m_pachLocalName;
  -    delete [] m_pachURI;
  +	if (NULL != m_pachPrefix)
  +	    delete [] m_pachPrefix;
  +	m_pachPrefix = NULL;
  +
  +	if (NULL != m_pachLocalName)
  +	    delete [] m_pachLocalName;
  +	m_pachLocalName = NULL;
  +
  +	if (NULL != m_pachURI)
  +	    delete [] m_pachURI;
  +	m_pachURI = NULL;
  +
       m_pParent = NULL;
   
       /* 
  @@ -171,6 +180,11 @@
   
   int ComplexElement::setPrefix(const AxisChar* pachPrefix)
   {
  +	if (NULL==pachPrefix)
  +		return AXIS_FAIL;
  +
  +	if (NULL != m_pachPrefix) 
  +		delete [] m_pachPrefix;
       m_pachPrefix = new AxisChar[strlen(pachPrefix)+1];
       strcpy(m_pachPrefix, pachPrefix);
       return AXIS_SUCCESS;
  @@ -178,6 +192,11 @@
   
   int ComplexElement::setLocalName(const AxisChar* pachLocalName)
   {
  +	if (NULL==pachLocalName)
  +		return AXIS_FAIL;
  +
  +	if (NULL != m_pachLocalName) 
  +		delete [] m_pachLocalName;
       m_pachLocalName = new AxisChar[strlen(pachLocalName)+1];
       strcpy(m_pachLocalName, pachLocalName);
       return AXIS_SUCCESS;
  @@ -210,12 +229,13 @@
           if(isSerializable()) 
           {    
               pSZ.serialize("<", NULL);    
  -            if(strlen(m_pachPrefix) != 0)
  +            if((NULL!=m_pachPrefix) && (strlen(m_pachPrefix)!=0))
               {                
                   pSZ.serialize(m_pachPrefix, ":", NULL);
               }
               pSZ.serialize(m_pachLocalName, NULL);
  -            if((strlen(m_pachPrefix) != 0) && (strlen(m_pachURI) != 0))
  +            if ((NULL!=m_pachPrefix) && (strlen(m_pachPrefix)!=0) && 
  +				(NULL!=m_pachURI) && (strlen(m_pachURI)!=0))
               {
                   pSZ.serialize(" xmlns:", m_pachPrefix, "=\"", m_pachURI, "\"",
                       NULL);
  @@ -227,7 +247,7 @@
                   break;
               }
               pSZ.serialize("</", NULL);
  -            if(strlen(m_pachPrefix) != 0)
  +            if((NULL!=m_pachPrefix) && (strlen(m_pachPrefix)!=0))
               {
                   pSZ.serialize(m_pachPrefix, ":", NULL);
               }
  @@ -284,6 +304,9 @@
               {
                   const AxisChar* pachTmp = pSZ.getNamespacePrefix(m_pachURI,
                       blnIsNewNamespace);
  +
  +				if (NULL!=m_pachPrefix)
  +					delete [] m_pachPrefix;
                   m_pachPrefix = new AxisChar[strlen(pachTmp)+1];
                   strcpy(m_pachPrefix , pachTmp);
   
  @@ -378,7 +401,7 @@
   
       do
       {
  -        if(strlen(m_pachLocalName) == 0)
  +        if((NULL==m_pachLocalName) || (strlen(m_pachLocalName)==0))
           {
               bStatus= false;
               break;
  @@ -390,6 +413,8 @@
   
   int ComplexElement::setURI(const AxisChar* pachURI)
   {
  +	if (NULL!=m_pachURI)
  +		delete [] m_pachURI;
       m_pachURI = new AxisChar[strlen(pachURI)+1];
       strcpy(m_pachURI, pachURI);
       return AXIS_SUCCESS;
  
  
  
  1.4       +0 -5      ws-axis/c/tests/auto_build/testcases/client/cpp/IHeaderBlockTest5Client.cpp
  
  Index: IHeaderBlockTest5Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tests/auto_build/testcases/client/cpp/IHeaderBlockTest5Client.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IHeaderBlockTest5Client.cpp	26 Feb 2005 07:31:03 -0000	1.3
  +++ IHeaderBlockTest5Client.cpp	1 Mar 2005 15:02:04 -0000	1.4
  @@ -39,11 +39,6 @@
   		BasicNode *ch=phb->createChild(CHARACTER_NODE,NULL,NULL,NULL,"AXISCPP");
   		Bnoden->addChild(ch);
   
  -		/*Test for NULL arguments. An element node Bnoden is created without any name */
  -		BasicNode * Bnoden1=phb->createImmediateChild(ELEMENT_NODE,NULL,NULL,NULL,NULL);
  -		if(Bnoden1==NULL)
  -			cout << "Null returned for Element_node" << endl;
  -		
   		BasicNode * Bnoden2=phb->createImmediateChild(CHARACTER_NODE,NULL,NULL,NULL,NULL);
   		if(Bnoden2==NULL)
   			cout << "Null returned for Character_node" << endl;
  
  
  
  1.4       +2 -2      ws-axis/c/tests/auto_build/testcases/output/IHeaderBlockTest5.expected
  
  Index: IHeaderBlockTest5.expected
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tests/auto_build/testcases/output/IHeaderBlockTest5.expected,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IHeaderBlockTest5.expected	26 Feb 2005 07:33:08 -0000	1.3
  +++ IHeaderBlockTest5.expected	1 Mar 2005 15:02:04 -0000	1.4
  @@ -1,8 +1,8 @@
   1
   Project Type=Open Source
  -No Of Children=8
  +No Of Children=7
   First Node Name = Project
  -Parent Node Name = Location Value =Sri Lanka
  +Parent Node Name = Project Value =AXISCPP
   Last Child Value=message
   5
   ---------------------- TEST COMPLETE -----------------------------
  
  
  

Mime
View raw message