static CharType *StrCopy(const CharType *src, size_t len)
{
CharType *dst = (CharType*)malloc(sizeof(CharType) * (len + 1));
- memcpy(dst, src, sizeof(CharType) * (len + 1));
+ if ( dst )
+ memcpy(dst, src, sizeof(CharType) * (len + 1));
return dst;
}
if ( !str )
return false;
+ // For consistency with the ctor taking just the length, NUL-terminate
+ // the buffer.
+ str[len] = (CharType)0;
+
if ( this->m_data == this->GetNullData() )
{
this->m_data = new Data(str, len);
friend class wxMemoryBuffer;
- // everyting is private as it can only be used by wxMemoryBuffer
+ // everything is private as it can only be used by wxMemoryBuffer
private:
wxMemoryBufferData(size_t size = wxMemoryBufferData::DefBufSize)
: m_data(size ? malloc(size) : NULL), m_size(size), m_len(0), m_ref(0)