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 169348 - get_special_folder() leakage
get_special_folder() leakage
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: win32
2.6.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
Depends on:
Blocks: 169349
 
 
Reported: 2005-03-06 01:14 UTC by Daniel Atallah
Modified: 2005-03-09 02:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix leaked retval of get_special_folder() (3.44 KB, patch)
2005-03-06 01:15 UTC, Daniel Atallah
none Details | Review
Improved patch (4.72 KB, patch)
2005-03-09 02:07 UTC, Tor Lillqvist
none Details | Review

Description Daniel Atallah 2005-03-06 01:14:42 UTC
In gutils.c, get_special_folder() returns the value returned by
g_utf16_to_utf8() or g_locale_to_utf8(), both of which return strings that need
to be freed (although g_locale_to_utf8() doesn't specifically mention it in the
API documentation).

Some places that get_special_folder() is used do not free the returned value
correctly (because it is being used in conjunction with static strings and
g_getenv() for non-windows application.

I don't see a way to attach a patch as part of the bug report step, so i'll
attach it as an additional step. :)
Comment 1 Daniel Atallah 2005-03-06 01:15:43 UTC
Created attachment 38324 [details] [review]
Fix leaked retval of get_special_folder()
Comment 2 Tor Lillqvist 2005-03-07 13:19:21 UTC
But on the other hand the leaks happen only once each, don't they?
Comment 3 Daniel Atallah 2005-03-07 13:25:43 UTC
Yes, they should happen only once.  I only noticed it while looking into Bug
#169349, I didn't set out looking for leaks.
Comment 4 Tor Lillqvist 2005-03-09 02:07:40 UTC
Created attachment 38442 [details] [review]
Improved patch

Improved patch that also guards against g_home_dir being NULL in these
functions. Also don't pass a NULL first parameter to g_strsplit().
Comment 5 Tor Lillqvist 2005-03-09 02:23:41 UTC
Committed to HEAD and glib-2-6.