[Patch] GTK2: Clipboard.AsText crashs sometimes.
Original Reporter info from Mantis: engkin @engkin
-
Reporter name:
Original Reporter info from Mantis: engkin @engkin
- Reporter name:
Description:
In \lcl\interfaces\gtk2\gtk2winapi.inc file, Function TGtk2WidgetSet.ClipboardGetData: SupportedFormats gets the same address from SelData.Data:
SupportedFormats:=PGdkAtom(SelData.Data);
at the end of ClipboardGetData both get freed:
finally
if SupportedFormats<>nil then FreeMem(SupportedFormats);
if SelData.Data<>nil then FreeMem(SelData.Data); //<--- this may cause a crash
end;
end;
The attached patch
Steps to reproduce:
Download the project which I'll attach in a comment.
Compile and run after using GTK2 as the widgetset.
Copy any image from the forum and click the button labeled "Clipboard.AsText".
Additional information:
Forum member dbannon (Davo) reported the issue here:
http://forum.lazarus.freepascal.org/index.php/topic,43750.0.html
He also provided a sample project which I'll include in this report in the first comment.
Mantis conversion info:
- Mantis ID: 34795
- OS: Linux/Win
- OS Build: any
- Version: 1.8.2
- Fixed in revision: r60064 (#6831ce0d)