Allow for zero-length string selections.

This commit is contained in:
Ulrich Czekalla 2000-11-25 01:26:02 +00:00 committed by Alexandre Julliard
parent f235a7ba04
commit 58445c9abf
1 changed files with 1 additions and 3 deletions

View File

@ -527,11 +527,10 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(UINT wFormat, Window w, Atom prop, At
for(i=0; i <= nitems; i++) for(i=0; i <= nitems; i++)
if( val[i] == '\n' ) inlcount++; if( val[i] == '\n' ) inlcount++;
if( nitems )
{
hText=GlobalAlloc16(GMEM_MOVEABLE, nitems + inlcount + 1); hText=GlobalAlloc16(GMEM_MOVEABLE, nitems + inlcount + 1);
if( (lpstr = (char*)GlobalLock16(hText)) ) if( (lpstr = (char*)GlobalLock16(hText)) )
{ {
ZeroMemory(lpstr, nitems + inlcount + 1);
for(i=0,inlcount=0; i <= nitems; i++) for(i=0,inlcount=0; i <= nitems; i++)
{ {
if( val[i] == '\n' ) lpstr[inlcount++]='\r'; if( val[i] == '\n' ) lpstr[inlcount++]='\r';
@ -541,7 +540,6 @@ static BOOL X11DRV_CLIPBOARD_ReadSelection(UINT wFormat, Window w, Atom prop, At
} }
else else
hText = 0; hText = 0;
}
if( hText ) if( hText )
{ {