After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 304633 - fix possible leak in _wnck_get_text_property
fix possible leak in _wnck_get_text_property
Status: RESOLVED FIXED
Product: libwnck
Classification: Core
Component: general
git master
Other Linux
: High normal
: ---
Assigned To: libwnck maintainers
libwnck maintainers
Depends on:
Blocks:
 
 
Reported: 2005-05-18 10:30 UTC by Benoît Dejean
Modified: 2005-05-27 14:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
possible fix (575 bytes, patch)
2005-05-18 10:34 UTC, Benoît Dejean
committed Details | Review

Description Benoît Dejean 2005-05-18 10:30:49 UTC
valgrind once reported this leak :

==6638== 8 bytes in 8 blocks are definitely lost in loss record 111 of 1079
==6638==    at 0x1B904EDD: malloc (vg_replace_malloc.c:131)
==6638==    by 0x1C3A4BD6: XGetWindowProperty (in /usr/X11R6/lib/libX11.so.6.2)
==6638==    by 0x1C3C26F1: XGetTextProperty (in /usr/X11R6/lib/libX11.so.6.2)
==6638==    by 0x1BC2BAEC: _wnck_get_text_property (xutils.c:268)
Comment 1 Benoît Dejean 2005-05-18 10:34:42 UTC
Created attachment 46593 [details] [review]
possible fix

i was not able to reproduce the leak, but i hope this patch fix it. I've
checked XFree documentation :

"An extra byte containing null (which is not included in the nitems member) is
stored at the end of the value field of text_prop_return."

So nitems may be 0 and value not null.
Comment 2 Benoît Dejean 2005-05-18 10:40:38 UTC
or may be the test if(text.value) is useless ...
Comment 3 Elijah Newren 2005-05-18 14:36:40 UTC
Yeah, Owen warned us about this in bug 133896; we really need someone to audit
both libwnck and metacity for XGetWindowProperty calls (though I think Kjartan
may have come along and fixed one or two already?).
Comment 4 Elijah Newren 2005-05-24 04:13:34 UTC
Okay, so I looked closer and I think your patch is right, but I'm getting a
little confused at the documentation (I'm looking at
http://tronche.com/gui/x/xlib/ICC/client-to-window-manager/XGetTextProperty.html).
 So I would like Vincent or Mark or Havoc to take a look as well.

(Also, as an aside, I did a grep for all the occurrences of XGetWindowProperty
that are called directly from libwnck and they seem to be handled; from your
valgrind stack trace it appears that XGetTextProperty calls XGetWindowProperty
so I searched for all of those and this appears to be the only one.  So I don't
think there's other similar leaks to plug).
Comment 5 Havoc Pennington 2005-05-27 14:24:54 UTC
Comment on attachment 46593 [details] [review]
possible fix

Thanks!