You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/10/22 19:53:05 UTC

cvs commit: xml-xerces/c/src/dom DOMString.cpp

tng         01/10/22 10:53:05

  Modified:    c/src/dom DOMString.cpp
  Log:
  [Bug 3660] Off-by-one error in DOMString.cpp.  And check that memory has been acquired successfully after memory acquistion requests in DOMString.
  
  Revision  Changes    Path
  1.23      +14 -2     xml-xerces/c/src/dom/DOMString.cpp
  
  Index: DOMString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/dom/DOMString.cpp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DOMString.cpp	2001/10/18 18:01:29	1.22
  +++ DOMString.cpp	2001/10/22 17:53:05	1.23
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: DOMString.cpp,v $
  + * Revision 1.23  2001/10/22 17:53:05  tng
  + * [Bug 3660] Off-by-one error in DOMString.cpp.  And check that memory has been acquired successfully after memory acquistion requests in DOMString.
  + *
    * Revision 1.22  2001/10/18 18:01:29  tng
    * [Bug 1699] Redirect "delete this" to a temp ptr to bypass AIX xlC v5 optimization memory leak problem.
    *
  @@ -206,7 +209,16 @@
       unsigned int sizeToAllocate = sizeof(DOMStringData) //  buffer will contain an
           + length*sizeof(XMLCh);                //  extra elem because of stub
                                                  //  array in DOMStringData struct.
  -    DOMStringData *buf = (DOMStringData *) new char[sizeToAllocate];
  +    DOMStringData *buf = 0;
  +    try {
  +        buf = (DOMStringData *) new char[sizeToAllocate];
  +    }
  +    catch (...) {
  +        ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory);
  +    }
  +    if (!buf)
  +       ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory);
  +
       XMLPlatformUtils::atomicIncrement(DOMString::gLiveStringDataCount);
       XMLPlatformUtils::atomicIncrement(DOMString::gTotalStringDataCount);
       buf->fBufferLength = length;
  @@ -652,7 +664,7 @@
       XMLCh *srcP = other.fHandle->fDSData->fData;
       XMLCh *destP = &fHandle->fDSData->fData[fHandle->fLength];
       unsigned int i;
  -    for (i=0; i<=other.fHandle->fLength; i++)
  +    for (i=0; i<other.fHandle->fLength; i++)
           destP[i] = srcP[i];
   
       fHandle->fLength += other.fHandle->fLength;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org