[Pkg-xfce-devel] Bug#692018: xfdesktop4: Possible memory leak in settings/main.c

Niels Thykier niels at thykier.net
Thu Nov 1 11:08:17 UTC 2012


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xfdesktop4.diff
Type: text/x-diff
Size: 682 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-xfce-devel/attachments/20121101/83fecb65/attachment-0001.diff>


More information about the Pkg-xfce-devel mailing list