Recent

Author Topic: Is there a leak when calling gtk_clipboard_wait_for_contents (gtk2)  (Read 1973 times)

WayneSherman

  • Full Member
  • ***
  • Posts: 243
This appears to be a leak when gtk_clipboard_wait_for_contents is called from gtk2proc.inc at line 7637.

Code: Pascal  [Select][+][-]
  1. if WaitForClipboardAnswer(EventData) then begin
  2.   gtk_clipboard_wait_for_contents(gtk_clipboard_get(TypeAtom), FormatID);
  3.   Result:=EventData^.Data;
  4. end;

The gtk2 docs for gtk-clipboard-wait-for-contents state:

Quote
Returns  a newly-allocated GtkSelectionData object or NULL if retrieving the given target failed. If non-NULL, this value must be freed with gtk_selection_data_free() when you are finished with it.

So if it returns non-NULL, GtkSelectionData must be freed, but the code in Lazarus is not capturing the return value.
« Last Edit: September 09, 2023, 09:29:35 pm by WayneSherman »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4508
  • I like bugs.
Re: Is there a leak when calling gtk_clipboard_wait_for_contents (gtk2)
« Reply #1 on: September 09, 2023, 09:38:07 pm »
Can you please provide a patch to fix it.
GTK memory leaks are difficult to notice because they don't usually show in normal heaptrace output.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: Is there a leak when calling gtk_clipboard_wait_for_contents (gtk2)
« Reply #2 on: September 10, 2023, 01:38:56 am »

 

TinyPortal © 2005-2018