[reSIProcate] String corruption?

david Butcher david at purplecomm.com
Tue Jul 12 17:21:01 CDT 2005


mSize should never be greater than mCapacity.

As an aside, c_str() is overly agressive about taking ownership of the 
buffer. I
will probably fix that.

david

Quoting Christian_Gavin at logitech.com:

> In os\data.cxx
>
> const char*
> Data::c_str() const
> {
>   own();
>
>   if (mSize >= mCapacity)      // !ah! we were overwritting the end
>   {                            // !ah! when mSize == mCapacity !!
>       const_cast<Data*>(this)->resize(mSize+1,true);
>   }
>   // mostly is zero terminated, but not by DataStream
>   mBuf[mSize] = 0;
>   return mBuf;
> }
>
> Does the comment imply that mSize should never be greater than mCapacity
> and if it was it would mean memory corruption? Could that explain the crash
> I am experiencing in the delete operator?
>
> Thanks!
> CG
>
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel at list.sipfoundry.org
> https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel
>





More information about the resiprocate-devel mailing list