[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#692018: marked as done (xfdesktop4: Possible memory leak in settings/main.c)



Your message dated Tue, 29 Nov 2022 22:30:18 +0500
with message-id <CANeoM1HJ5UikJ4cO1-hZqe3hNXX1Pik=y7doAxaEzG+UEB=L8g@mail.gmail.com>
and subject line Re: xfdesktop4: Possible memory leak in settings/main.c
has caused the Debian Bug report #692018,
regarding xfdesktop4: Possible memory leak in settings/main.c
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
692018: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=692018
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: xfdesktop4
Version: 4.8.3-2
Severity: normal
Tags: upstream

Hi,

cppcheck brought the following code snippet in settings/main.c to my
attention.  Unlike #692016, this appears to be a real leak:

"""
    PreviewData *pdata = g_new0(PreviewData, 1);

    pdata->model = g_object_ref(G_OBJECT(model));

    if(TARGET_TEXT_URI_LIST != info
        || selection_data->format != 8
        || selection_data->length <= 0)
    {
        gtk_drag_finish(context, FALSE, FALSE, time_);
        return;
    }
    [...]
"""

It seems to both cppcheck and me that pdata is leaked if the condition
for this if-statement is true.  Also, model may be leaked due to the
g_object_ref call.

I cannot find any ownership passing (or any use) of pdata or model in
the "body" of the if-statement.  I attached an untested proposed
solution, which is to defer memory allocation and ref'ing till after
the "if" (i.e. at the [...] part).

The code snippet appears in 4.10.0, so if you agree with my assertion,
4.10.0 is also affected.

~Niels
--- settings/main.c.orig	2012-11-01 11:54:34.540623096 +0100
+++ settings/main.c	2012-11-01 11:56:46.288626451 +0100
@@ -1087,9 +1087,7 @@
     gboolean file_added;
     gchar *p;
     GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
-    PreviewData *pdata = g_new0(PreviewData, 1);
-
-    pdata->model = g_object_ref(G_OBJECT(model));
+    PreviewData *pdata;
 
     if(TARGET_TEXT_URI_LIST != info
         || selection_data->format != 8
@@ -1099,6 +1097,9 @@
         return;
     }
 
+    pdata = g_new0(PreviewData, 1);
+    pdata->model = g_object_ref(G_OBJECT(model));
+
     p = (gchar *)selection_data->data;
     while(*p) {
         if(*p != '#') {

--- End Message ---
--- Begin Message ---
Source: xfdesktop4
Source-Version: 4.11.2-1

--- End Message ---

Reply to: