Skip to content

Commit

Permalink
Windows: Fixed off-by-one error when dropping Unicode text
Browse files Browse the repository at this point in the history
and wrong data size value.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8028 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Albrecht Schlosser committed Dec 14, 2010
1 parent 5889675 commit 1f0da65
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fl_dnd_win32.cxx
Expand Up @@ -216,7 +216,7 @@ class FLDropTarget : public IDropTarget
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;
Expand All @@ -229,12 +229,12 @@ class FLDropTarget : public IDropTarget
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;
Expand All @@ -259,7 +259,7 @@ class FLDropTarget : public IDropTarget
q += len;
}
*q = 0;
currDragSize = q - Fl::e_text;
currDragSize = q - currDragData;
currDragData = (char*)realloc(currDragData, currDragSize + 1);
GlobalUnlock( medium.hGlobal );
ReleaseStgMedium( &medium );
Expand Down

0 comments on commit 1f0da65

Please sign in to comment.