openbsd-ports/x11/wxWidgets/patches/patch-src_common_string_cpp
todd b25888b419 wxWidgets 2.4.2, C++ cross-platform GUI toolkit
www: http://www.wxwidgets.org/

from Andrew Dalgleish   < openbsd at ajd dot net dot au >
many thanks for much persistence!
2004-07-16 21:01:35 +00:00

21 lines
773 B
Plaintext

$OpenBSD: patch-src_common_string_cpp,v 1.1.1.1 2004/07/16 21:01:35 todd Exp $
--- src/common/string.cpp.orig 2003-09-20 20:24:26.000000000 +1000
+++ src/common/string.cpp 2003-10-04 13:24:11.000000000 +1000
@@ -1514,10 +1514,12 @@ wxString& wxString::insert(size_t nPos,
if ( !str.IsEmpty() ) {
wxString strTmp;
- wxChar *pc = strTmp.GetWriteBuf(Len() + str.Len());
- wxStrncpy(pc, c_str(), nPos);
- wxStrcpy(pc + nPos, str);
- wxStrcpy(pc + nPos + str.Len(), c_str() + nPos);
+ size_t newLen = Len() + str.Len() + 1;
+ wxChar *pc = strTmp.GetWriteBuf(newLen);
+ strlcpy(pc, c_str(), newLen);
+ pc[nPos] = 0;
+ strlcat(pc, str, newLen);
+ strlcat(pc, c_str() + nPos, newLen);
strTmp.UngetWriteBuf();
*this = strTmp;
}