mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 22:58:14 +02:00
LCL-GTK2: Fix double free due to wrong refcount during SaveDC/RestoreDC
CopyDataFrom copies the FPixmap field directly without updating reference counts for the objects, which in some cases ends up attempting to unref (in the TGtkDeviceContext destructor) an already freed object (this can happen when, e.g., SaveDC/RestoreDC is called twice with the same DC - in the first SaveDC/RestoreDC "pass", RestoreDC deletes the FPixmap object during the saved context destruction and in the second "pass" the object is already destroyed and the program crashes). This patch fixes this by adding calls to ref/unref during CopyDataFrom for the FPixmap.
This commit is contained in:
parent
ca9f504a0d
commit
5ecce8dc19
@ -681,6 +681,8 @@ begin
|
||||
|
||||
FWithChildWindows := ASource.FWithChildWindows;
|
||||
FDrawable := ASource.FDrawable;
|
||||
if Assigned(ASource.FPixbuf) then gdk_pixbuf_ref(ASource.FPixbuf);
|
||||
if Assigned(FPixbuf) then gdk_pixbuf_unref(FPixbuf);
|
||||
FPixbuf := ASource.Pixbuf;
|
||||
FOriginalDrawable := ASource.FOriginalDrawable;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user