GNOME Bugzilla – Bug 679347
glocalfile seems to leak 'fstype'
Last modified: 2017-11-15 13:18:23 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
clearly confused. get_fs_type returns a static string
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
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>