Windows: Fixed off-by-one error when dropping Unicode text

and wrong data size value.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8028 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2010-12-14 19:46:55 +00:00
parent 5889675f7d
commit 1f0da65165

View File

@ -216,7 +216,7 @@ private:
clearCurrentDragData();
currDragRef = data;
// fill currDrag* with ASCII data, if available
// fill currDrag* with UTF-8 data, if available
FORMATETC fmt = { 0 };
STGMEDIUM medium = { 0 };
fmt.tymed = TYMED_HGLOBAL;
@ -229,12 +229,12 @@ private:
void *stuff = GlobalLock( medium.hGlobal );
unsigned srclen = 0;
const wchar_t *wstuff = (const wchar_t *)stuff;
while(*wstuff++) srclen++;
while (*wstuff++) srclen++;
wstuff = (const wchar_t *)stuff;
unsigned utf8len = fl_utf8fromwc(NULL, 0, wstuff, srclen);
currDragSize = utf8len;
currDragData = (char*)malloc(utf8len + 1);
fl_utf8fromwc(currDragData, currDragSize, wstuff, srclen);
fl_utf8fromwc(currDragData, currDragSize+1, wstuff, srclen+1); // include null-byte
GlobalUnlock( medium.hGlobal );
ReleaseStgMedium( &medium );
currDragResult = 1;
@ -259,7 +259,7 @@ private:
q += len;
}
*q = 0;
currDragSize = q - Fl::e_text;
currDragSize = q - currDragData;
currDragData = (char*)realloc(currDragData, currDragSize + 1);
GlobalUnlock( medium.hGlobal );
ReleaseStgMedium( &medium );