X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d87c0ac7b9a25c9268f33ed0f2235a851fd91958..4875458c3e56c10f92e6ba9d85bea68435386beb:/include/wx/buffer.h diff --git a/include/wx/buffer.h b/include/wx/buffer.h index 87b0507022..a1547764c7 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -14,8 +14,8 @@ #ifndef _WX_BUFFER_H #define _WX_BUFFER_H +#include "wx/wxchar.h" #include // strdup -#include // wchar_t // ---------------------------------------------------------------------------- // Special classes for (wide) character strings: they use malloc/free instead @@ -66,9 +66,12 @@ public: { wxASSERT_MSG( wcs, _T("NULL string in wxWCharBuffer") ); - m_wcs = wcs ? (wchar_t *)malloc((wcslen(wcs)+1)*sizeof(wchar_t)) - : (wchar_t *)NULL; - if (m_wcs) wcscpy(m_wcs, wcs); + if (wcs) { + size_t siz = (wcslen(wcs)+1)*sizeof(wchar_t); + m_wcs = (wchar_t *)malloc(siz); + memcpy(m_wcs, wcs, siz); + } + else m_wcs = (wchar_t *)NULL; } wxWCharBuffer(size_t len) { @@ -83,13 +86,13 @@ public: { m_wcs = src.m_wcs; // no reference count yet... - (wxWCharBuffer)src.m_wcs = (wchar_t *)NULL; + ((wxWCharBuffer*)&src)->m_wcs = (wchar_t *)NULL; } wxWCharBuffer& operator=(const wxWCharBuffer& src) { m_wcs = src.m_wcs; // no reference count yet... - (wxWCharBuffer)src.m_wcs = (wchar_t *)NULL; + ((wxWCharBuffer*)&src)->m_wcs = (wchar_t *)NULL; return *this; }