Fixed a buffer overflow in fl_utf8from_mb() (STR #2279).

Todo: fix _WIN32 vs. WIN32 compiler macro issues.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7021 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser
2010-01-22 16:56:34 +00:00
parent ff29502d04
commit 430eab49b7
2 changed files with 7 additions and 6 deletions
+3 -2
View File
@@ -1,9 +1,10 @@
CHANGES IN FLTK 1.3.0
- Fixed a buffer overflow in fl_utf8from_mb() (STR #2279)
- Fixed a Windows GDI leak when testing alpha blending capabilities
- Fixed a name conflict with new (VC 2008 Express) winsock2.h
- Fixed a name conflict with new (VS 2008 Express) winsock2.h
versions and another conflict that produced compile errors
with VC 2008 (STR #2301).
with VS 2008 Express (STR #2301)
- Widgets now remove stale entries from the default callback
queue when they are deleted (STR #2302)
- Moved OS X code base to the more moder Cocoa toolkit thanks
+4 -4
View File
@@ -776,13 +776,13 @@ unsigned fl_utf8from_mb(char* dst, unsigned dstlen,
{
if (!fl_utf8locale()) {
#ifdef _WIN32
#warning _WIN32 alarm
wchar_t lbuf[1024];
wchar_t* buf = lbuf;
unsigned length;
unsigned ret;
length =
MultiByteToWideChar(GetACP(), 0, src, srclen, buf, 1024);
if (length >= 1024) {
length = MultiByteToWideChar(GetACP(), 0, src, srclen, buf, 1024);
if ((length == 0)&&(GetLastError()==ERROR_INSUFFICIENT_BUFFER)) {
length = MultiByteToWideChar(GetACP(), 0, src, srclen, 0, 0);
buf = (wchar_t*)(malloc(length*sizeof(wchar_t)));
MultiByteToWideChar(GetACP(), 0, src, srclen, buf, length);
@@ -798,7 +798,7 @@ unsigned fl_utf8from_mb(char* dst, unsigned dstlen,
length = mbstowcs(buf, src, 1024);
if (length >= 1024) {
length = mbstowcs(0, src, 0)+1;
buf = (wchar_t*)(malloc(length*sizeof(unsigned short)));
buf = (wchar_t*)(malloc(length*sizeof(wchar_t)));
mbstowcs(buf, src, length);
}
if (length >= 0) {