< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index  

RE: [reSIProcate] String corruption fix


Thanks Christian - I've committed your fix.

-----Original Message-----
From: Christian_Gavin@xxxxxxxxxxxx [mailto:Christian_Gavin@xxxxxxxxxxxx] 
Sent: Wednesday, July 13, 2005 12:29 PM
To: resiprocate-devel@xxxxxxxxxxxxxxxxxxx
Subject: [reSIProcate] String corruption fix

Hi,

Here is the fix I made locally to data.cxx

Data&
Data::append(const char* str, size_type len)
{
   assert(str);
   if (mCapacity < mSize + len)
   {
      // .dlb. pad for future growth?
      resize(((mSize + len +16)*3)/2, true);
   }
   else
   {
      if (mMine == Share)
      {
         char *oldBuf = mBuf;
         mCapacity = mSize + len;
         mBuf = new char[mSize + len + 1];      // << FIX here: added +1 to
account for extra '\0' !
         memcpy(mBuf, oldBuf, mSize);
         mMine = Take;
      }
   }

   // could conceivably overlap
   memmove(mBuf + mSize, str, len);
   mSize += len;
   mBuf[mSize] = 0;

   return *this;
}

It solved the memory corruption problem when appending strings.

Please consider applying this fix to the subversion repository.

Thanks,
CG

_______________________________________________
resiprocate-devel mailing list
resiprocate-devel@xxxxxxxxxxxxxxxxxxx
https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel