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 679347 - glocalfile seems to leak 'fstype'
glocalfile seems to leak 'fstype'
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-07-03 19:44 UTC by Allison Karlitskaya (desrt)
Modified: 2017-11-15 13:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
glocalfile: Fix leak of FS type on some platforms (1.52 KB, patch)
2017-11-15 13:18 UTC, Philip Withnall
committed Details | Review

Description Allison Karlitskaya (desrt) 2012-07-03 19:44:40 UTC
in g_local_file_query_filesystem_info() we see

  const char *fstype;

followed by some lines like these:

#ifdef USE_STATFS
#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME)
  fstype = g_strdup (statfs_buffer.f_fstypename);
#else
  fstype = get_fs_type (statfs_buffer.f_type);
#endif

#elif defined(USE_STATVFS)
#if defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)
  fstype = g_strdup (statfs_buffer.f_fstypename);
#elif defined(HAVE_STRUCT_STATVFS_F_BASETYPE)
  fstype = g_strdup (statfs_buffer.f_basetype);
#else
  fstype = NULL;
#endif
Comment 1 Matthias Clasen 2012-07-03 19:53:10 UTC
clearly confused. get_fs_type returns a static string
Comment 2 Philip Withnall 2017-11-15 13:18:17 UTC
Fixed (pushed without review because it seemed sufficiently trivial).

The following fix has been pushed:
d4f07f2 glocalfile: Fix leak of FS type on some platforms
Comment 3 Philip Withnall 2017-11-15 13:18:23 UTC
Created attachment 363680 [details] [review]
glocalfile: Fix leak of FS type on some platforms

fstype is a const char*, and is passed to
g_file_info_set_attribute_string(), which takes a copy of it. There’s no
need to g_strdup() the FS type from various statfs/statvfs buffers
beforehand, given that the buffers are valid for the duration of this
function.

Signed-off-by: Philip Withnall <withnall@endlessm.com>