GTK2: Remove trailing NULL only when GTK_REMOVE_CLIPBOARD_NULL is defined. Issues #21453 and #31547.

git-svn-id: trunk@55180 -
This commit is contained in:
juha 2017-06-03 08:56:31 +00:00
parent 7026faf61d
commit abec998f34

View File

@ -3578,9 +3578,11 @@ begin
GetMem(Buffer,BufLength);
Assert(Assigned(Buffer) and (BufLength>0), 'SetData: GTK2 clipboard Buffer=Nil or empty.');
MemStream.Read(Buffer^,BufLength);
{$IFDEF GTK_REMOVE_CLIPBOARD_NULL}
// Issue #21453. gtk_selection_data_set adds the required null. Remove it here.
if PChar(Buffer+BufLength-1)^ = #0 then
dec(BufLength);
{$ENDIF}
gtk_selection_data_set(SelectionData,SelectionData^.Target,8,Buffer,BufLength);
FreeMem(Buffer);
end;