summaryrefslogtreecommitdiffstats
path: root/qtools
diff options
context:
space:
mode:
Diffstat (limited to 'qtools')
-rw-r--r--qtools/qstring.cpp12
-rw-r--r--qtools/scstring.cpp2
-rw-r--r--qtools/scstring.h1
3 files changed, 9 insertions, 6 deletions
diff --git a/qtools/qstring.cpp b/qtools/qstring.cpp
index 4707fed..e073168 100644
--- a/qtools/qstring.cpp
+++ b/qtools/qstring.cpp
@@ -15156,16 +15156,18 @@ QCString qt_winQString2MB( const QString& s, int uclen )
if ( uclen == 0 )
return QCString();
BOOL used_def;
- QCString mb(4096);
+ int bufSize=4096;
+ QCString mb(bufSize);
int len;
while ( !(len=WideCharToMultiByte(CP_ACP, 0, (const WCHAR*)s.unicode(), uclen,
- mb.data(), mb.size()-1, 0, &used_def)) )
+ mb.data(), bufSize-1, 0, &used_def)) )
{
int r = GetLastError();
if ( r == ERROR_INSUFFICIENT_BUFFER ) {
- mb.resize(1+WideCharToMultiByte( CP_ACP, 0,
- (const WCHAR*)s.unicode(), uclen,
- 0, 0, 0, &used_def));
+ bufSize=1+WideCharToMultiByte( CP_ACP, 0,
+ (const WCHAR*)s.unicode(), uclen,
+ 0, 0, 0, &used_def);
+ mb.resize(bufSize);
// and try again...
} else {
// Fail.
diff --git a/qtools/scstring.cpp b/qtools/scstring.cpp
index ebf54a9..a265afe 100644
--- a/qtools/scstring.cpp
+++ b/qtools/scstring.cpp
@@ -34,7 +34,7 @@ SCString::SCString(int size)
m_data = (char *)malloc(size);
if (m_data)
{
- m_data[0]='\0';
+ if (size>1) memset(m_data,' ',size-1);
m_data[size-1]='\0';
}
}
diff --git a/qtools/scstring.h b/qtools/scstring.h
index 0c388b8..41dcfac 100644
--- a/qtools/scstring.h
+++ b/qtools/scstring.h
@@ -144,6 +144,7 @@ inline void SCString::duplicate( const char *str)
}
inline SCString &SCString::duplicate( const char *str, int)
{
+ if (m_data) free(m_data);
duplicate(str);
return *this;
}