X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/43b282bd095529e69f0bf7e7bd44888e4867257e..c437b3f4e47b74715a2f2385d4862972babd7802:/src/common/strvararg.cpp?ds=inline diff --git a/src/common/strvararg.cpp b/src/common/strvararg.cpp index e89bdf35b5..e71c060b10 100644 --- a/src/common/strvararg.cpp +++ b/src/common/strvararg.cpp @@ -152,7 +152,7 @@ public: m_nCopied = 0; } - wxCharTypeBuffer Convert(const CharType *format) + wxScopedCharTypeBuffer Convert(const CharType *format) { // this is reset to NULL if we modify the format string m_fmtOrig = format; @@ -263,12 +263,14 @@ public: // format if ( m_fmtOrig ) { - return wxCharTypeBuffer::CreateNonOwned(m_fmtOrig); + return wxScopedCharTypeBuffer::CreateNonOwned(m_fmtOrig); } else { - // NULL-terminate converted format string: - *m_fmtLast = 0; + // shrink converted format string to actual size (instead of + // over-sized allocation from CopyAllBefore()) and NUL-terminate + // it: + m_fmt.shrink(m_fmtLast - m_fmt.data()); return m_fmt; } }