X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/846b6c86586ff3c5a1948132761ba223f3ccb75c..a4f6fe43c33bd7933645d110ad2719871dab043d:/include/wx/buffer.h diff --git a/include/wx/buffer.h b/include/wx/buffer.h index 800c41b714..951777a13c 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -230,7 +230,8 @@ protected: 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; } @@ -312,6 +313,10 @@ public: 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); @@ -434,7 +439,7 @@ public: 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)