Revision: 3927
http://svn.sourceforge.net/winmerge/?rev=3927&view=rev
Author: kimmov
Date: 2006-12-07 10:15:50 -0800 (Thu, 07 Dec 2006)
Log Message:
-----------
PATCH: [ 1556688 ] Fix maketstring to check for zero-term by MultiByteToWideCha
Modified Paths:
--------------
branches/R2_6/Src/Changes.txt
branches/R2_6/Src/Common/unicoder.cpp
Modified: branches/R2_6/Src/Changes.txt
===================================================================
--- branches/R2_6/Src/Changes.txt 2006-12-07 18:09:14 UTC (rev 3926)
+++ branches/R2_6/Src/Changes.txt 2006-12-07 18:15:50 UTC (rev 3927)
@@ -9,6 +9,8 @@
html.cpp innosetup.cpp is.cpp java.cpp lisp.cpp nsis.cpp. pascal.cpp perl.cpp php.cpp
python.cpp rexx.cpp rsrc.cpp ruby.cpp sgml.cpp sh.cpp siod.cpp sql.cpp tcl.cpp tex.cpp
xml.cpp
+ PATCH: [ 1556688 ] Fix maketstring to check for zero-term by MultiByteToWideCha
+ Src: Common/unicoder.cpp
2006-12-04 Tim
PATCH: [ 1607193 ] INI Syntax Improvements
Modified: branches/R2_6/Src/Common/unicoder.cpp
===================================================================
--- branches/R2_6/Src/Common/unicoder.cpp 2006-12-07 18:09:14 UTC (rev 3926)
+++ branches/R2_6/Src/Common/unicoder.cpp 2006-12-07 18:15:50 UTC (rev 3927)
@@ -502,6 +502,15 @@
int n = MultiByteToWideChar(codepage, flags, lpd, len, wbuff, wlen-1);
if (n)
{
+ /*
+ NB: MultiByteToWideChar is documented as only zero-terminating
+ if input was zero-terminated, but it appears that it can
+ zero-terminate even if input wasn't.
+ So we check if it zero-terminated and adjust count accordingly.
+ */
+ if (wbuff[n-1] == 0)
+ --n;
+
str.ReleaseBuffer(n);
return str;
}
@@ -515,6 +524,15 @@
n = MultiByteToWideChar(codepage, flags, lpd, len, wbuff, wlen-1);
if (n)
{
+ /*
+ NB: MultiByteToWideChar is documented as only zero-terminating
+ if input was zero-terminated, but it appears that it can
+ zero-terminate even if input wasn't.
+ So we check if it zero-terminated and adjust count accordingly.
+ */
+ if (wbuff[n-1] == 0)
+ --n;
+
str.ReleaseBuffer(n);
return str;
}
@@ -582,6 +600,14 @@
dest[0] = '?';
return 1;
}
+ /*
+ NB: MultiByteToWideChar is documented as only zero-terminating
+ if input was zero-terminated, but it appears that it can
+ zero-terminate even if input wasn't.
+ So we check if it zero-terminated and adjust count accordingly.
+ */
+ if (wbuff[n-1] == 0)
+ --n;
wbuff[n] = 0; // zero-terminate string
// Now convert to TCHAR (which means defcodepage)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|