Merge pull request #1121 from bpay/fix-buffer-overflows

Fix buffer overflows
This commit is contained in:
Luis Anton Rebollo 2015-02-02 20:15:51 +01:00
commit cc9be50422
20 changed files with 112 additions and 114 deletions

View file

@ -141,7 +141,7 @@ void StringBuffer::set(const UTF8 *in)
incRequestCount8(); incRequestCount8();
// Convert and store. Note that a UTF16 version of the string cannot be longer. // Convert and store. Note that a UTF16 version of the string cannot be longer.
FrameTemp<UTF16> tmpBuff(dStrlen(in)+1); FrameTemp<UTF16> tmpBuff(dStrlen(in)+1);
if(!in || in[0] == 0 || !convertUTF8toUTF16(in, tmpBuff, dStrlen(in)+1)) if(!in || in[0] == 0 || !convertUTF8toUTF16N(in, tmpBuff, dStrlen(in)+1))
{ {
// Easy out, it's a blank string, or a bad string. // Easy out, it's a blank string, or a bad string.
mBuffer.clear(); mBuffer.clear();
@ -186,7 +186,7 @@ void StringBuffer::append(const UTF8* in)
// convert to UTF16, because that's our internal format. // convert to UTF16, because that's our internal format.
// if the conversion fails, exit. // if the conversion fails, exit.
UTF16* tmp = convertUTF8toUTF16(in); UTF16* tmp = createUTF16string(in);
AssertFatal(tmp, "StringBuffer::append(UTF8) - could not convert UTF8 string!"); AssertFatal(tmp, "StringBuffer::append(UTF8) - could not convert UTF8 string!");
if(!tmp) if(!tmp)
return; return;
@ -231,7 +231,7 @@ void StringBuffer::insert(const U32 charOffset, const UTF8* in)
// convert to UTF16, because that's our internal format. // convert to UTF16, because that's our internal format.
// if the conversion fails, exit. // if the conversion fails, exit.
UTF16* tmp = convertUTF8toUTF16(in); UTF16* tmp = createUTF16string(in);
AssertFatal(tmp, "StringBuffer::insert(UTF8) - could not convert UTF8 string!"); AssertFatal(tmp, "StringBuffer::insert(UTF8) - could not convert UTF8 string!");
if(!tmp) if(!tmp)
return; return;
@ -359,7 +359,7 @@ void StringBuffer::getCopy8(UTF8 *buff, const U32 buffSize) const
{ {
incRequestCount8(); incRequestCount8();
AssertFatal(mBuffer.last() == 0, "StringBuffer::get UTF8 - not a null terminated string!"); AssertFatal(mBuffer.last() == 0, "StringBuffer::get UTF8 - not a null terminated string!");
convertUTF16toUTF8(mBuffer.address(), buff, buffSize); convertUTF16toUTF8N(mBuffer.address(), buff, buffSize);
} }
void StringBuffer::getCopy(UTF16 *buff, const U32 buffSize) const void StringBuffer::getCopy(UTF16 *buff, const U32 buffSize) const
@ -377,7 +377,7 @@ UTF8* StringBuffer::createCopy8() const
incRequestCount8(); incRequestCount8();
// convert will create a buffer of the appropriate size for a null terminated // convert will create a buffer of the appropriate size for a null terminated
// input string. // input string.
UTF8* out = convertUTF16toUTF8(mBuffer.address()); UTF8* out = createUTF8string(mBuffer.address());
return out; return out;
} }
@ -408,7 +408,7 @@ void StringBuffer::updateBuffer8()
{ {
U32 slackLen = getUTF8BufferSizeEstimate(); U32 slackLen = getUTF8BufferSizeEstimate();
mBuffer8.setSize(slackLen); mBuffer8.setSize(slackLen);
U32 len = convertUTF16toUTF8(mBuffer.address(), mBuffer8.address(), slackLen); U32 len = convertUTF16toUTF8N(mBuffer.address(), mBuffer8.address(), slackLen);
mBuffer8.setSize(len+1); mBuffer8.setSize(len+1);
mBuffer8.compact(); mBuffer8.compact();
mDirty8 = false; mDirty8 = false;

View file

@ -146,7 +146,7 @@ inline bool isAboveBMP(U32 codepoint)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
U32 convertUTF8toUTF16(const UTF8 *unistring, UTF16 *outbuffer, U32 len) U32 convertUTF8toUTF16N(const UTF8 *unistring, UTF16 *outbuffer, U32 len)
{ {
AssertFatal(len >= 1, "Buffer for unicode conversion must be large enough to hold at least the null terminator."); AssertFatal(len >= 1, "Buffer for unicode conversion must be large enough to hold at least the null terminator.");
PROFILE_SCOPE(convertUTF8toUTF16); PROFILE_SCOPE(convertUTF8toUTF16);
@ -159,7 +159,6 @@ U32 convertUTF8toUTF16(const UTF8 *unistring, UTF16 *outbuffer, U32 len)
{ {
const UTF16Cache &cache = (*cacheItr).value; const UTF16Cache &cache = (*cacheItr).value;
cache.copyToBuffer(outbuffer, len); cache.copyToBuffer(outbuffer, len);
outbuffer[len-1] = '\0';
return getMin(cache.mLength,len - 1); return getMin(cache.mLength,len - 1);
} }
#endif #endif
@ -191,7 +190,7 @@ U32 convertUTF8toUTF16(const UTF8 *unistring, UTF16 *outbuffer, U32 len)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
U32 convertUTF16toUTF8( const UTF16 *unistring, UTF8 *outbuffer, U32 len) U32 convertUTF16toUTF8N( const UTF16 *unistring, UTF8 *outbuffer, U32 len)
{ {
AssertFatal(len >= 1, "Buffer for unicode conversion must be large enough to hold at least the null terminator."); AssertFatal(len >= 1, "Buffer for unicode conversion must be large enough to hold at least the null terminator.");
PROFILE_START(convertUTF16toUTF8); PROFILE_START(convertUTF16toUTF8);
@ -243,16 +242,16 @@ U32 convertUTF16toUTF8DoubleNULL( const UTF16 *unistring, UTF8 *outbuffer, U32
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Functions that convert buffers of unicode code points // Functions that convert buffers of unicode code points
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
UTF16* convertUTF8toUTF16( const UTF8* unistring) UTF16* createUTF16string( const UTF8* unistring)
{ {
PROFILE_SCOPE(convertUTF8toUTF16_create); PROFILE_SCOPE(createUTF16string);
// allocate plenty of memory. // allocate plenty of memory.
U32 nCodepoints, len = dStrlen(unistring) + 1; U32 nCodepoints, len = dStrlen(unistring) + 1;
FrameTemp<UTF16> buf(len); FrameTemp<UTF16> buf(len);
// perform conversion // perform conversion
nCodepoints = convertUTF8toUTF16( unistring, buf, len); nCodepoints = convertUTF8toUTF16N( unistring, buf, len);
// add 1 for the NULL terminator the converter promises it included. // add 1 for the NULL terminator the converter promises it included.
nCodepoints++; nCodepoints++;
@ -265,16 +264,16 @@ UTF16* convertUTF8toUTF16( const UTF8* unistring)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
UTF8* convertUTF16toUTF8( const UTF16* unistring) UTF8* createUTF8string( const UTF16* unistring)
{ {
PROFILE_SCOPE(convertUTF16toUTF8_create); PROFILE_SCOPE(createUTF8string);
// allocate plenty of memory. // allocate plenty of memory.
U32 nCodeunits, len = dStrlen(unistring) * 3 + 1; U32 nCodeunits, len = dStrlen(unistring) * 3 + 1;
FrameTemp<UTF8> buf(len); FrameTemp<UTF8> buf(len);
// perform conversion // perform conversion
nCodeunits = convertUTF16toUTF8( unistring, buf, len); nCodeunits = convertUTF16toUTF8N( unistring, buf, len);
// add 1 for the NULL terminator the converter promises it included. // add 1 for the NULL terminator the converter promises it included.
nCodeunits++; nCodeunits++;
@ -509,21 +508,6 @@ U32 dStrlen(const UTF32 *unistring)
return i; return i;
} }
//-----------------------------------------------------------------------------
U32 dStrncmp(const UTF16* unistring1, const UTF16* unistring2, U32 len)
{
UTF16 c1, c2;
for(U32 i = 0; i<len; i++)
{
c1 = *unistring1++;
c2 = *unistring2++;
if(c1 < c2) return -1;
if(c1 > c2) return 1;
if(!c1) return 0;
}
return 0;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const UTF16* dStrrchr(const UTF16* unistring, U32 c) const UTF16* dStrrchr(const UTF16* unistring, U32 c)

View file

@ -62,9 +62,9 @@
/// calling delete[] on these buffers. /// calling delete[] on these buffers.
/// - Because they allocate memory, do not use these functions in a tight loop. /// - Because they allocate memory, do not use these functions in a tight loop.
/// - These are useful when you need a new long term copy of a string. /// - These are useful when you need a new long term copy of a string.
UTF16* convertUTF8toUTF16( const UTF8 *unistring); UTF16* createUTF16string( const UTF8 *unistring);
UTF8* convertUTF16toUTF8( const UTF16 *unistring); UTF8* createUTF8string( const UTF16 *unistring);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/// Functions that convert buffers of unicode code points, into a provided buffer. /// Functions that convert buffers of unicode code points, into a provided buffer.
@ -79,9 +79,23 @@ UTF8* convertUTF16toUTF8( const UTF16 *unistring);
/// - Output is null terminated. Be sure to provide 1 extra byte, U16 or U32 for /// - Output is null terminated. Be sure to provide 1 extra byte, U16 or U32 for
/// the null terminator, or you will see truncated output. /// the null terminator, or you will see truncated output.
/// - If the provided buffer is too small, the output will be truncated. /// - If the provided buffer is too small, the output will be truncated.
U32 convertUTF8toUTF16(const UTF8 *unistring, UTF16 *outbuffer, U32 len); U32 convertUTF8toUTF16N(const UTF8 *unistring, UTF16 *outbuffer, U32 len);
U32 convertUTF16toUTF8( const UTF16 *unistring, UTF8 *outbuffer, U32 len); U32 convertUTF16toUTF8N( const UTF16 *unistring, UTF8 *outbuffer, U32 len);
/// Safe conversion function for statically sized buffers.
template <size_t N>
inline U32 convertUTF8toUTF16(const UTF8 *unistring, UTF16 (&outbuffer)[N])
{
return convertUTF8toUTF16N(unistring, outbuffer, (U32) N);
}
/// Safe conversion function for statically sized buffers.
template <size_t N>
inline U32 convertUTF16toUTF8(const UTF16 *unistring, UTF8 (&outbuffer)[N])
{
return convertUTF16toUTF8N(unistring, outbuffer, (U32) N);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/// Functions that converts one unicode codepoint at a time /// Functions that converts one unicode codepoint at a time
@ -105,10 +119,6 @@ U32 oneUTF32toUTF8( const UTF32 codepoint, UTF8 *threeByteCodeunitBuf);
U32 dStrlen(const UTF16 *unistring); U32 dStrlen(const UTF16 *unistring);
U32 dStrlen(const UTF32 *unistring); U32 dStrlen(const UTF32 *unistring);
//-----------------------------------------------------------------------------
/// Comparing unicode strings
U32 dStrncmp(const UTF16* unistring1, const UTF16* unistring2, U32 len);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/// Scanning for characters in unicode strings /// Scanning for characters in unicode strings
UTF16* dStrrchr(UTF16* unistring, U32 c); UTF16* dStrrchr(UTF16* unistring, U32 c);

View file

@ -346,7 +346,7 @@ class String::StringData : protected StringDataImpl
{ {
// Do this atomically to protect interned strings. // Do this atomically to protect interned strings.
UTF16* utf16 = convertUTF8toUTF16( mData ); UTF16* utf16 = createUTF16string( mData );
if( !dCompareAndSwap( mUTF16,( UTF16* ) NULL, utf16 ) ) if( !dCompareAndSwap( mUTF16,( UTF16* ) NULL, utf16 ) )
delete [] utf16; delete [] utf16;
} }
@ -580,7 +580,7 @@ String::String(const UTF16 *str)
if( str && str[ 0 ] ) if( str && str[ 0 ] )
{ {
UTF8* utf8 = convertUTF16toUTF8( str ); UTF8* utf8 = createUTF8string( str );
U32 len = dStrlen( utf8 ); U32 len = dStrlen( utf8 );
_string = new ( len ) StringData( utf8 ); _string = new ( len ) StringData( utf8 );
delete [] utf8; delete [] utf8;

View file

@ -44,7 +44,7 @@ protected:
: mData( str ), mLength( str ? dStrlen( str ) : 0 ), mUTF16( NULL ) : mData( str ), mLength( str ? dStrlen( str ) : 0 ), mUTF16( NULL )
{ {
if( str ) if( str )
mUTF16 = convertUTF8toUTF16( mData ); mUTF16 = createUTF16string( mData );
} }
~StrTest() ~StrTest()
{ {

View file

@ -423,7 +423,7 @@ U32 GFont::getStrNWidth(const UTF8 *str, U32 n)
{ {
// UTF8 conversion is expensive. Avoid converting in a tight loop. // UTF8 conversion is expensive. Avoid converting in a tight loop.
FrameTemp<UTF16> str16(n + 1); FrameTemp<UTF16> str16(n + 1);
convertUTF8toUTF16(str, str16, n + 1); convertUTF8toUTF16N(str, str16, n + 1);
return getStrNWidth(str16, dStrlen(str16)); return getStrNWidth(str16, dStrlen(str16));
} }
@ -462,7 +462,7 @@ U32 GFont::getStrNWidth(const UTF16 *str, U32 n)
U32 GFont::getStrNWidthPrecise(const UTF8 *str, U32 n) U32 GFont::getStrNWidthPrecise(const UTF8 *str, U32 n)
{ {
FrameTemp<UTF16> str16(n + 1); FrameTemp<UTF16> str16(n + 1);
convertUTF8toUTF16(str, str16, n + 1); convertUTF8toUTF16N(str, str16, n + 1);
return getStrNWidthPrecise(str16, dStrlen(str16)); return getStrNWidthPrecise(str16, dStrlen(str16));
} }

View file

@ -148,8 +148,8 @@ U32 GFXDrawUtil::drawTextN( GFont *font, const Point2I &ptDraw, const UTF8 *in_s
// Convert to UTF16 temporarily. // Convert to UTF16 temporarily.
n++; // space for null terminator n++; // space for null terminator
FrameTemp<UTF16> ubuf( n * sizeof(UTF16) ); FrameTemp<UTF16> ubuf( n );
convertUTF8toUTF16(in_string, ubuf, n); convertUTF8toUTF16N(in_string, ubuf, n);
return drawTextN( font, ptDraw, ubuf, n, colorTable, maxColorIndex, rot ); return drawTextN( font, ptDraw, ubuf, n, colorTable, maxColorIndex, rot );
} }

View file

@ -279,7 +279,7 @@ void GuiTextEditCtrl::setText( const UTF16* txt)
{ {
if(txt && txt[0] != 0) if(txt && txt[0] != 0)
{ {
UTF8* txt8 = convertUTF16toUTF8( txt ); UTF8* txt8 = createUTF8string( txt );
Parent::setText( txt8 ); Parent::setText( txt8 );
delete[] txt8; delete[] txt8;
mTextBuffer.set( txt ); mTextBuffer.set( txt );

View file

@ -79,7 +79,7 @@ static LRESULT PASCAL OKBtnFolderHackProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
char *filePath; char *filePath;
#ifdef UNICODE #ifdef UNICODE
char fileBuf[MAX_PATH]; char fileBuf[MAX_PATH];
convertUTF16toUTF8(ofn->lpstrFile, fileBuf, sizeof(fileBuf)); convertUTF16toUTF8(ofn->lpstrFile, fileBuf);
filePath = fileBuf; filePath = fileBuf;
#else #else
filePath = ofn->lpstrFile; filePath = ofn->lpstrFile;
@ -140,7 +140,7 @@ static UINT_PTR CALLBACK FolderHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPA
char filePath[MAX_PATH]; char filePath[MAX_PATH];
#ifdef UNICODE #ifdef UNICODE
convertUTF16toUTF8(buf, filePath, sizeof(filePath)); convertUTF16toUTF8(buf, filePath);
#else #else
dStrcpy( filePath, buf ); dStrcpy( filePath, buf );
#endif #endif
@ -158,7 +158,7 @@ static UINT_PTR CALLBACK FolderHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPA
#ifdef UNICODE #ifdef UNICODE
char buf2[MAX_PATH]; char buf2[MAX_PATH];
convertUTF16toUTF8(buf, buf2, sizeof(buf2)); convertUTF16toUTF8(buf, buf2);
#else #else
char *buf2 = buf; char *buf2 = buf;
#endif #endif
@ -324,10 +324,10 @@ bool FileDialog::Execute()
UTF16 pszFileTitle[MAX_PATH]; UTF16 pszFileTitle[MAX_PATH];
UTF16 pszDefaultExtension[MAX_PATH]; UTF16 pszDefaultExtension[MAX_PATH];
// Convert parameters to UTF16*'s // Convert parameters to UTF16*'s
convertUTF8toUTF16((UTF8 *)mData.mDefaultFile, pszFile, sizeof(pszFile)); convertUTF8toUTF16((UTF8 *)mData.mDefaultFile, pszFile);
convertUTF8toUTF16((UTF8 *)mData.mDefaultPath, pszInitialDir, sizeof(pszInitialDir)); convertUTF8toUTF16((UTF8 *)mData.mDefaultPath, pszInitialDir);
convertUTF8toUTF16((UTF8 *)mData.mTitle, pszTitle, sizeof(pszTitle)); convertUTF8toUTF16((UTF8 *)mData.mTitle, pszTitle);
convertUTF8toUTF16((UTF8 *)mData.mFilters, pszFilter, sizeof(pszFilter) ); convertUTF8toUTF16((UTF8 *)mData.mFilters, pszFilter);
#else #else
// Not Unicode, All char*'s! // Not Unicode, All char*'s!
char pszFile[MAX_PATH]; char pszFile[MAX_PATH];
@ -442,7 +442,7 @@ bool FileDialog::Execute()
// Handle Result Properly for Unicode as well as ANSI // Handle Result Properly for Unicode as well as ANSI
#ifdef UNICODE #ifdef UNICODE
if(pszFileTitle[0] || ! ( mData.mStyle & FileDialogData::FDS_OPEN && mData.mStyle & FileDialogData::FDS_MULTIPLEFILES )) if(pszFileTitle[0] || ! ( mData.mStyle & FileDialogData::FDS_OPEN && mData.mStyle & FileDialogData::FDS_MULTIPLEFILES ))
convertUTF16toUTF8( (UTF16*)pszFile, (UTF8*)pszResult, sizeof(pszResult)); convertUTF16toUTF8( (UTF16*)pszFile, pszResult);
else else
convertUTF16toUTF8DoubleNULL( (UTF16*)pszFile, (UTF8*)pszResult, sizeof(pszResult)); convertUTF16toUTF8DoubleNULL( (UTF16*)pszFile, (UTF8*)pszResult, sizeof(pszResult));
#else #else

View file

@ -101,8 +101,8 @@ S32 Platform::messageBox(const UTF8 *title, const UTF8 *message, MBButtons butto
pWindow->setCursorVisible(true); pWindow->setCursorVisible(true);
#ifdef UNICODE #ifdef UNICODE
const UTF16 *msg = convertUTF8toUTF16(message); const UTF16 *msg = createUTF16string(message);
const UTF16 *t = convertUTF8toUTF16(title); const UTF16 *t = createUTF16string(title);
#else #else
const UTF8 *msg = message; const UTF8 *msg = message;
const UTF8 *t = title; const UTF8 *t = title;

View file

@ -67,7 +67,7 @@ void WinConsole::enable(bool enabled)
{ {
#ifdef UNICODE #ifdef UNICODE
UTF16 buf[512]; UTF16 buf[512];
convertUTF8toUTF16((UTF8 *)title, buf, sizeof(buf)); convertUTF8toUTF16((UTF8 *)title, buf);
SetConsoleTitle(buf); SetConsoleTitle(buf);
#else #else
SetConsoleTitle(title); SetConsoleTitle(title);

View file

@ -588,7 +588,7 @@ const char* DInputDevice::getName()
{ {
#ifdef UNICODE #ifdef UNICODE
static UTF8 buf[512]; static UTF8 buf[512];
convertUTF16toUTF8(mDeviceInstance.tszInstanceName, buf, sizeof(buf)); convertUTF16toUTF8(mDeviceInstance.tszInstanceName, buf);
return (const char *)buf; return (const char *)buf;
#else #else
return mDeviceInstance.tszInstanceName; return mDeviceInstance.tszInstanceName;
@ -600,7 +600,7 @@ const char* DInputDevice::getProductName()
{ {
#ifdef UNICODE #ifdef UNICODE
static UTF8 buf[512]; static UTF8 buf[512];
convertUTF16toUTF8(mDeviceInstance.tszProductName, buf, sizeof(buf)); convertUTF16toUTF8(mDeviceInstance.tszProductName, buf);
return (const char *)buf; return (const char *)buf;
#else #else
return mDeviceInstance.tszProductName; return mDeviceInstance.tszProductName;

View file

@ -88,15 +88,15 @@ ExecuteThread::ExecuteThread(const char *executable, const char *args /* = NULL
#ifdef UNICODE #ifdef UNICODE
WCHAR exe[ 1024 ]; WCHAR exe[ 1024 ];
convertUTF8toUTF16( exeBuf, exe, sizeof( exe ) / sizeof( exe[ 0 ] ) ); convertUTF8toUTF16( exeBuf, exe );
TempAlloc< WCHAR > argsBuf( ( args ? dStrlen( args ) : 0 ) + 1 ); TempAlloc< WCHAR > argsBuf( ( args ? dStrlen( args ) : 0 ) + 1 );
argsBuf[ argsBuf.size - 1 ] = 0; argsBuf[ argsBuf.size - 1 ] = 0;
if( args ) if( args )
convertUTF8toUTF16( args, argsBuf, argsBuf.size ); convertUTF8toUTF16N( args, argsBuf, argsBuf.size );
if( directory ) if( directory )
convertUTF8toUTF16( directory, dirBuf, dirBuf.size ); convertUTF8toUTF16N( directory, dirBuf, dirBuf.size );
#else #else
char* exe = exeBuf; char* exe = exeBuf;
char* argsBuf = args; char* argsBuf = args;
@ -162,7 +162,7 @@ void Platform::openFolder(const char* path )
#ifdef UNICODE #ifdef UNICODE
WCHAR p[ 1024 ]; WCHAR p[ 1024 ];
convertUTF8toUTF16( filePath, p, sizeof( p ) / sizeof( p[ 0 ] ) ); convertUTF8toUTF16( filePath, p );
#else #else
char* p = filePath; char* p = filePath;
#endif #endif
@ -179,7 +179,7 @@ void Platform::openFile(const char* path )
#ifdef UNICODE #ifdef UNICODE
WCHAR p[ 1024 ]; WCHAR p[ 1024 ];
convertUTF8toUTF16( filePath, p, sizeof( p ) / sizeof( p[ 0 ] ) ); convertUTF8toUTF16( filePath, p );
#else #else
char* p = filePath; char* p = filePath;
#endif #endif

View file

@ -54,7 +54,7 @@ bool dFileDelete(const char * name)
TempAlloc< TCHAR > buf( dStrlen( name ) + 1 ); TempAlloc< TCHAR > buf( dStrlen( name ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( name, buf, buf.size ); convertUTF8toUTF16N( name, buf, buf.size );
#else #else
dStrcpy( buf, name ); dStrcpy( buf, name );
#endif #endif
@ -74,8 +74,8 @@ bool dFileRename(const char *oldName, const char *newName)
TempAlloc< TCHAR > newf( dStrlen( newName ) + 1 ); TempAlloc< TCHAR > newf( dStrlen( newName ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( oldName, oldf, oldf.size ); convertUTF8toUTF16N( oldName, oldf, oldf.size );
convertUTF8toUTF16( newName, newf, newf.size ); convertUTF8toUTF16N( newName, newf, newf.size );
#else #else
dStrcpy(oldf, oldName); dStrcpy(oldf, oldName);
dStrcpy(newf, newName); dStrcpy(newf, newName);
@ -93,7 +93,7 @@ bool dFileTouch(const char * name)
TempAlloc< TCHAR > buf( dStrlen( name ) + 1 ); TempAlloc< TCHAR > buf( dStrlen( name ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( name, buf, buf.size ); convertUTF8toUTF16N( name, buf, buf.size );
#else #else
dStrcpy( buf, name ); dStrcpy( buf, name );
#endif #endif
@ -119,8 +119,8 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
TempAlloc< TCHAR > to( dStrlen( toName ) + 1 ); TempAlloc< TCHAR > to( dStrlen( toName ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( fromName, from, from.size ); convertUTF8toUTF16N( fromName, from, from.size );
convertUTF8toUTF16( toName, to, to.size ); convertUTF8toUTF16N( toName, to, to.size );
#else #else
dStrcpy( from, fromName ); dStrcpy( from, fromName );
dStrcpy( to, toName ); dStrcpy( to, toName );
@ -187,8 +187,8 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
backslash(toFile); backslash(toFile);
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( tempBuf, wtempBuf, wtempBuf.size ); convertUTF8toUTF16N( tempBuf, wtempBuf, wtempBuf.size );
convertUTF8toUTF16( tempBuf1, wtempBuf1, wtempBuf1.size ); convertUTF8toUTF16N( tempBuf1, wtempBuf1, wtempBuf1.size );
WCHAR* f = wtempBuf1; WCHAR* f = wtempBuf1;
WCHAR* t = wtempBuf; WCHAR* t = wtempBuf;
#else #else
@ -256,7 +256,7 @@ File::FileStatus File::open(const char *filename, const AccessMode openMode)
TempAlloc< TCHAR > fname( dStrlen( filename ) + 1 ); TempAlloc< TCHAR > fname( dStrlen( filename ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( filename, fname, fname.size ); convertUTF8toUTF16N( filename, fname, fname.size );
#else #else
dStrcpy(fname, filename); dStrcpy(fname, filename);
#endif #endif
@ -586,7 +586,7 @@ static bool recurseDumpPath(const char *path, const char *pattern, Vector<Platfo
#ifdef UNICODE #ifdef UNICODE
TempAlloc< WCHAR > searchBuf( buf.size ); TempAlloc< WCHAR > searchBuf( buf.size );
convertUTF8toUTF16( buf, searchBuf, searchBuf.size ); convertUTF8toUTF16N( buf, searchBuf, searchBuf.size );
WCHAR* search = searchBuf; WCHAR* search = searchBuf;
#else #else
char *search = buf; char *search = buf;
@ -601,7 +601,7 @@ static bool recurseDumpPath(const char *path, const char *pattern, Vector<Platfo
do do
{ {
#ifdef UNICODE #ifdef UNICODE
convertUTF16toUTF8( findData.cFileName, buf, buf.size ); convertUTF16toUTF8N( findData.cFileName, buf, buf.size );
char* fnbuf = buf; char* fnbuf = buf;
#else #else
char *fnbuf = findData.cFileName; char *fnbuf = findData.cFileName;
@ -665,7 +665,7 @@ bool Platform::getFileTimes(const char *filePath, FileTime *createTime, FileTime
TempAlloc< TCHAR > fp( dStrlen( filePath ) + 1 ); TempAlloc< TCHAR > fp( dStrlen( filePath ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( filePath, fp, fp.size ); convertUTF8toUTF16N( filePath, fp, fp.size );
#else #else
dStrcpy( fp, filePath ); dStrcpy( fp, filePath );
#endif #endif
@ -697,7 +697,7 @@ bool Platform::createPath(const char *file)
#ifdef UNICODE #ifdef UNICODE
TempAlloc< WCHAR > fileBuf( pathbuf.size ); TempAlloc< WCHAR > fileBuf( pathbuf.size );
convertUTF8toUTF16( file, fileBuf, fileBuf.size ); convertUTF8toUTF16N( file, fileBuf, fileBuf.size );
const WCHAR* fileName = fileBuf; const WCHAR* fileName = fileBuf;
const WCHAR* dir; const WCHAR* dir;
#else #else
@ -802,7 +802,7 @@ StringTableEntry Platform::getCurrentDirectory()
forwardslash( buf ); forwardslash( buf );
#ifdef UNICODE #ifdef UNICODE
char* utf8 = convertUTF16toUTF8( buf ); char* utf8 = createUTF8string( buf );
StringTableEntry result = StringTable->insert( utf8 ); StringTableEntry result = StringTable->insert( utf8 );
SAFE_DELETE_ARRAY( utf8 ); SAFE_DELETE_ARRAY( utf8 );
return result; return result;
@ -820,7 +820,7 @@ bool Platform::setCurrentDirectory(StringTableEntry newDir)
TempAlloc< TCHAR > buf( dStrlen( newDir ) + 2 ); TempAlloc< TCHAR > buf( dStrlen( newDir ) + 2 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( newDir, buf, buf.size - 1 ); convertUTF8toUTF16N( newDir, buf, buf.size - 1 );
#else #else
dStrcpy( buf, newDir ); dStrcpy( buf, newDir );
#endif #endif
@ -847,8 +847,8 @@ static void getExecutableInfo( StringTableEntry* path, StringTableEntry* exe )
if( delimiter ) if( delimiter )
*delimiter = '\0'; *delimiter = '\0';
char* pathBuf = convertUTF16toUTF8( cen_buf ); char* pathBuf = createUTF8string( cen_buf );
char* exeBuf = convertUTF16toUTF8( delimiter + 1 ); char* exeBuf = createUTF8string( delimiter + 1 );
pathEntry = StringTable->insert( pathBuf ); pathEntry = StringTable->insert( pathBuf );
exeEntry = StringTable->insert( exeBuf ); exeEntry = StringTable->insert( exeBuf );
@ -935,7 +935,7 @@ bool Platform::isFile(const char *pFilePath)
TempAlloc< TCHAR > buf( dStrlen( pFilePath ) + 1 ); TempAlloc< TCHAR > buf( dStrlen( pFilePath ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( pFilePath, buf, buf.size ); convertUTF8toUTF16N( pFilePath, buf, buf.size );
#else #else
dStrcpy( buf, pFilePath ); dStrcpy( buf, pFilePath );
#endif #endif
@ -974,7 +974,7 @@ S32 Platform::getFileSize(const char *pFilePath)
TempAlloc< TCHAR > buf( dStrlen( pFilePath ) + 1 ); TempAlloc< TCHAR > buf( dStrlen( pFilePath ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( pFilePath, buf, buf.size ); convertUTF8toUTF16N( pFilePath, buf, buf.size );
#else #else
dStrcpy( buf, pFilePath ); dStrcpy( buf, pFilePath );
#endif #endif
@ -1011,7 +1011,7 @@ bool Platform::isDirectory(const char *pDirPath)
TempAlloc< TCHAR > buf( dStrlen( pDirPath ) + 1 ); TempAlloc< TCHAR > buf( dStrlen( pDirPath ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( pDirPath, buf, buf.size ); convertUTF8toUTF16N( pDirPath, buf, buf.size );
#else #else
dStrcpy( buf, pDirPath ); dStrcpy( buf, pDirPath );
#endif #endif
@ -1057,8 +1057,8 @@ bool Platform::isSubDirectory(const char *pParent, const char *pDir)
TempAlloc< TCHAR > dir( dStrlen( pDir ) + 1 ); TempAlloc< TCHAR > dir( dStrlen( pDir ) + 1 );
#ifdef UNICODE #ifdef UNICODE
convertUTF8toUTF16( fileName, file, file.size ); convertUTF8toUTF16N( fileName, file, file.size );
convertUTF8toUTF16( pDir, dir, dir.size ); convertUTF8toUTF16N( pDir, dir, dir.size );
#else #else
dStrcpy( file, fileName ); dStrcpy( file, fileName );
dStrcpy( dir, pDir ); dStrcpy( dir, pDir );
@ -1213,10 +1213,10 @@ void Platform::getVolumeInformationList( Vector<VolumeInformation>& out_rVolumeI
#ifdef UNICODE #ifdef UNICODE
char buf[ sizeof( lpszFileSystem ) / sizeof( lpszFileSystem[ 0 ] ) * 3 + 1 ]; char buf[ sizeof( lpszFileSystem ) / sizeof( lpszFileSystem[ 0 ] ) * 3 + 1 ];
convertUTF16toUTF8( lpszFileSystem, buf, sizeof( buf ) / sizeof( buf[ 0 ] ) ); convertUTF16toUTF8( lpszFileSystem, buf );
info.FileSystem = StringTable->insert( buf ); info.FileSystem = StringTable->insert( buf );
convertUTF16toUTF8( lpszVolumeName, buf, sizeof( buf ) / sizeof( buf[ 0 ] ) ); convertUTF16toUTF8( lpszVolumeName, buf );
info.Name = StringTable->insert( buf ); info.Name = StringTable->insert( buf );
#else #else
info.FileSystem = StringTable->insert( lpszFileSystem ); info.FileSystem = StringTable->insert( lpszFileSystem );
@ -1251,7 +1251,7 @@ bool Platform::hasSubDirectory(const char *pPath)
#ifdef UNICODE #ifdef UNICODE
WCHAR buf[ 1024 ]; WCHAR buf[ 1024 ];
convertUTF8toUTF16( searchBuf, buf, sizeof( buf ) / sizeof( buf[ 0 ] ) ); convertUTF8toUTF16( searchBuf, buf );
WCHAR* search = buf; WCHAR* search = buf;
#else #else
char* search = searchBuf; char* search = searchBuf;
@ -1276,7 +1276,7 @@ bool Platform::hasSubDirectory(const char *pPath)
#ifdef UNICODE #ifdef UNICODE
char fileName[ 1024 ]; char fileName[ 1024 ];
convertUTF16toUTF8( findData.cFileName, fileName, sizeof( fileName ) / sizeof( fileName[ 0 ] ) ); convertUTF16toUTF8( findData.cFileName, fileName );
#else #else
char* fileName = findData.cFileName; char* fileName = findData.cFileName;
#endif #endif
@ -1335,7 +1335,7 @@ static bool recurseDumpDirectories(const char *basePath, const char *subPath, Ve
#ifdef UNICODE #ifdef UNICODE
TempAlloc< WCHAR > searchStr( dStrlen( search ) + 1 ); TempAlloc< WCHAR > searchStr( dStrlen( search ) + 1 );
convertUTF8toUTF16( search, searchStr, searchStr.size ); convertUTF8toUTF16N( search, searchStr, searchStr.size );
#else #else
char* searchStr = search; char* searchStr = search;
#endif #endif
@ -1397,7 +1397,7 @@ static bool recurseDumpDirectories(const char *basePath, const char *subPath, Ve
continue; continue;
#ifdef UNICODE #ifdef UNICODE
convertUTF16toUTF8( findData.cFileName, fileName, fileName.size ); convertUTF16toUTF8N( findData.cFileName, fileName, fileName.size );
#else #else
char* fileName = findData.cFileName; char* fileName = findData.cFileName;
#endif #endif
@ -1472,7 +1472,7 @@ StringTableEntry osGetTemporaryDirectory()
#ifdef UNICODE #ifdef UNICODE
TempAlloc< char > dirBuffer( len * 3 + 1 ); TempAlloc< char > dirBuffer( len * 3 + 1 );
char* dir = dirBuffer; char* dir = dirBuffer;
convertUTF16toUTF8( buffer, dir, dirBuffer.size ); convertUTF16toUTF8N( buffer, dir, dirBuffer.size );
#else #else
char* dir = buf; char* dir = buf;
#endif #endif

View file

@ -104,7 +104,7 @@ BOOL CALLBACK EnumFamCallBack(LPLOGFONT logFont, LPNEWTEXTMETRIC textMetric, DWO
const U32 len = dStrlen( logFont->lfFaceName ) * 3 + 1; const U32 len = dStrlen( logFont->lfFaceName ) * 3 + 1;
FrameTemp<UTF8> buffer( len ); FrameTemp<UTF8> buffer( len );
convertUTF16toUTF8( logFont->lfFaceName, buffer, len ); convertUTF16toUTF8N( logFont->lfFaceName, buffer, len );
fonts->push_back( StringTable->insert( buffer ) ); fonts->push_back( StringTable->insert( buffer ) );

View file

@ -144,7 +144,7 @@ bool Win32RedBookDevice::open()
openParms.lpstrDeviceType = (LPCWSTR)MCI_DEVTYPE_CD_AUDIO; openParms.lpstrDeviceType = (LPCWSTR)MCI_DEVTYPE_CD_AUDIO;
UTF16 buf[512]; UTF16 buf[512];
convertUTF8toUTF16((UTF8 *)mDeviceName, buf, sizeof(buf)); convertUTF8toUTF16((UTF8 *)mDeviceName, buf);
openParms.lpstrElementName = buf; openParms.lpstrElementName = buf;
#else #else
openParms.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO; openParms.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO;

View file

@ -52,7 +52,7 @@ const char *Platform::getUserDataDirectory()
#ifdef UNICODE #ifdef UNICODE
char path[ MAX_PATH * 3 + 1 ]; char path[ MAX_PATH * 3 + 1 ];
convertUTF16toUTF8( szBuffer, path, sizeof( path ) ); convertUTF16toUTF8( szBuffer, path );
#else #else
char* path = szBuffer; char* path = szBuffer;
#endif #endif
@ -78,7 +78,7 @@ const char *Platform::getUserHomeDirectory()
#ifdef UNICODE #ifdef UNICODE
char path[ MAX_PATH * 3 + 1 ]; char path[ MAX_PATH * 3 + 1 ];
convertUTF16toUTF8( szBuffer, path, sizeof( path ) ); convertUTF16toUTF8( szBuffer, path );
#else #else
char* path = szBuffer; char* path = szBuffer;
#endif #endif

View file

@ -720,13 +720,13 @@ String Platform::FS::getAssetDir()
{ {
TCHAR buf[ 2048 ]; TCHAR buf[ 2048 ];
::GetModuleFileNameW( NULL, buf, sizeof( buf ) ); ::GetModuleFileNameW( NULL, buf, sizeof( buf ) );
convertUTF16toUTF8( buf, cen_buf, sizeof( cen_buf ) ); convertUTF16toUTF8( buf, cen_buf );
} }
else else
{ {
TCHAR buf[ 2048 ]; TCHAR buf[ 2048 ];
GetCurrentDirectoryW( sizeof( buf ) / sizeof( buf[ 0 ] ), buf ); GetCurrentDirectoryW( sizeof( buf ) / sizeof( buf[ 0 ] ), buf );
convertUTF16toUTF8( buf, cen_buf, sizeof( cen_buf ) ); convertUTF16toUTF8( buf, cen_buf );
return Path::CleanSeparators(cen_buf); return Path::CleanSeparators(cen_buf);
} }
#else #else

View file

@ -104,7 +104,7 @@ bool Platform::excludeOtherInstances(const char *mutexName)
{ {
#ifdef UNICODE #ifdef UNICODE
UTF16 b[512]; UTF16 b[512];
convertUTF8toUTF16((UTF8 *)mutexName, b, sizeof(b)); convertUTF8toUTF16((UTF8 *)mutexName, b);
gMutexHandle = CreateMutex(NULL, true, b); gMutexHandle = CreateMutex(NULL, true, b);
#else #else
gMutexHandle = CreateMutex(NULL, true, mutexName); gMutexHandle = CreateMutex(NULL, true, mutexName);
@ -164,7 +164,7 @@ bool Platform::checkOtherInstances(const char *mutexName)
#ifdef UNICODE #ifdef UNICODE
UTF16 b[512]; UTF16 b[512];
convertUTF8toUTF16((UTF8 *)mutexName, b, sizeof(b)); convertUTF8toUTF16((UTF8 *)mutexName, b);
pMutex = CreateMutex(NULL, true, b); pMutex = CreateMutex(NULL, true, b);
#else #else
pMutex = CreateMutex(NULL, true, mutexName); pMutex = CreateMutex(NULL, true, mutexName);
@ -197,8 +197,8 @@ void Platform::AlertOK(const char *windowTitle, const char *message)
ShowCursor(true); ShowCursor(true);
#ifdef UNICODE #ifdef UNICODE
UTF16 m[1024], t[512]; UTF16 m[1024], t[512];
convertUTF8toUTF16((UTF8 *)windowTitle, t, sizeof(t)); convertUTF8toUTF16((UTF8 *)windowTitle, t);
convertUTF8toUTF16((UTF8 *)message, m, sizeof(m)); convertUTF8toUTF16((UTF8 *)message, m);
MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK); MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK);
#else #else
MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK); MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OK);
@ -211,8 +211,8 @@ bool Platform::AlertOKCancel(const char *windowTitle, const char *message)
ShowCursor(true); ShowCursor(true);
#ifdef UNICODE #ifdef UNICODE
UTF16 m[1024], t[512]; UTF16 m[1024], t[512];
convertUTF8toUTF16((UTF8 *)windowTitle, t, sizeof(t)); convertUTF8toUTF16((UTF8 *)windowTitle, t);
convertUTF8toUTF16((UTF8 *)message, m, sizeof(m)); convertUTF8toUTF16((UTF8 *)message, m);
return MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK; return MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK;
#else #else
return MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK; return MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_OKCANCEL) == IDOK;
@ -225,8 +225,8 @@ bool Platform::AlertRetry(const char *windowTitle, const char *message)
ShowCursor(true); ShowCursor(true);
#ifdef UNICODE #ifdef UNICODE
UTF16 m[1024], t[512]; UTF16 m[1024], t[512];
convertUTF8toUTF16((UTF8 *)windowTitle, t, sizeof(t)); convertUTF8toUTF16((UTF8 *)windowTitle, t);
convertUTF8toUTF16((UTF8 *)message, m, sizeof(m)); convertUTF8toUTF16((UTF8 *)message, m);
return (MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY); return (MessageBox(NULL, m, t, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY);
#else #else
return (MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY); return (MessageBox(NULL, message, windowTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TASKMODAL | MB_RETRYCANCEL) == IDRETRY);
@ -241,8 +241,8 @@ Platform::ALERT_ASSERT_RESULT Platform::AlertAssert(const char *windowTitle, con
#ifdef UNICODE #ifdef UNICODE
UTF16 messageUTF[1024], title[512]; UTF16 messageUTF[1024], title[512];
convertUTF8toUTF16((UTF8 *)windowTitle, title, sizeof(title)); convertUTF8toUTF16((UTF8 *)windowTitle, title);
convertUTF8toUTF16((UTF8 *)message, messageUTF, sizeof(messageUTF)); convertUTF8toUTF16((UTF8 *)message, messageUTF);
#else #else
const char* messageUTF = message; const char* messageUTF = message;
const char* title = windowTitle; const char* title = windowTitle;
@ -362,7 +362,7 @@ S32 WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
{ {
TCHAR buf[ moduleNameSize ]; TCHAR buf[ moduleNameSize ];
GetModuleFileNameW( NULL, buf, moduleNameSize ); GetModuleFileNameW( NULL, buf, moduleNameSize );
convertUTF16toUTF8( buf, moduleName, moduleNameSize ); convertUTF16toUTF8( buf, moduleName );
} }
#else #else
GetModuleFileNameA(NULL, moduleName, moduleNameSize); GetModuleFileNameA(NULL, moduleName, moduleNameSize);
@ -440,7 +440,7 @@ S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
{ {
TCHAR buf[ moduleNameSize ]; TCHAR buf[ moduleNameSize ];
GetModuleFileNameW( NULL, buf, moduleNameSize ); GetModuleFileNameW( NULL, buf, moduleNameSize );
convertUTF16toUTF8( buf, moduleName, moduleNameSize ); convertUTF16toUTF8( buf, moduleName );
} }
#else #else
GetModuleFileNameA(NULL, moduleName, moduleNameSize); GetModuleFileNameA(NULL, moduleName, moduleNameSize);
@ -541,7 +541,7 @@ bool Platform::openWebBrowser( const char* webAddress )
RegCloseKey( regKey ); RegCloseKey( regKey );
sHaveKey = true; sHaveKey = true;
convertUTF16toUTF8(sWebKey,utf8WebKey,512); convertUTF16toUTF8(sWebKey,utf8WebKey);
#ifdef UNICODE #ifdef UNICODE
char *p = dStrstr((const char *)utf8WebKey, "%1"); char *p = dStrstr((const char *)utf8WebKey, "%1");
@ -560,7 +560,7 @@ bool Platform::openWebBrowser( const char* webAddress )
#ifdef UNICODE #ifdef UNICODE
dSprintf( buf, sizeof( buf ), "%s %s", utf8WebKey, webAddress ); dSprintf( buf, sizeof( buf ), "%s %s", utf8WebKey, webAddress );
UTF16 b[1024]; UTF16 b[1024];
convertUTF8toUTF16((UTF8 *)buf, b, sizeof(b)); convertUTF8toUTF16((UTF8 *)buf, b);
#else #else
dSprintf( buf, sizeof( buf ), "%s %s", sWebKey, webAddress ); dSprintf( buf, sizeof( buf ), "%s %s", sWebKey, webAddress );
#endif #endif

View file

@ -150,7 +150,7 @@ static HCURSOR gCursorShape = NULL;
void Win32CursorController::setCursorShape( const UTF8 *fileName, bool reload ) void Win32CursorController::setCursorShape( const UTF8 *fileName, bool reload )
{ {
#ifdef UNICODE #ifdef UNICODE
const UTF16 *lFileName = convertUTF8toUTF16( fileName ); const UTF16 *lFileName = createUTF16string( fileName );
#else #else
const UTF8 *lFileName = fileName; const UTF8 *lFileName = fileName;
#endif #endif
@ -160,6 +160,10 @@ void Win32CursorController::setCursorShape( const UTF8 *fileName, bool reload )
if ( gCursorShape ) if ( gCursorShape )
SetCursor( gCursorShape ); SetCursor( gCursorShape );
#ifdef UNICODE
delete[] lFileName;
#endif
} }
// Console function to set the current cursor shape given the cursor shape // Console function to set the current cursor shape given the cursor shape