path: root/fileset.c
diff options
authorPeter Wu <peter@lekensteyn.nl>2016-02-03 18:28:46 +0100
committerAnders Broman <a.broman58@gmail.com>2016-02-04 04:57:30 +0000
commit8899e006aab3e0831214d187596eef450b5e21b7 (patch)
tree83b3aebc1c31dcdbd89cb229202b186e6fc57356 /fileset.c
parent36cf75efb15827c801c4e82c8ab3ed16f3e00749 (diff)
Fix memleaks related to get_dirname
get_dirname may return NULL instead of the original string, so avoid patterns like get_dirname(strdup(x)). Writing to cf_path.toUtf8().data() is fine btw, toUtf8() returns new memory. This fixes two memleak reported by LeakSanitizer via fileset_add_dir and MainWindow::captureFileReadFinished (both via cf_callback_invoke). Change-Id: I0f1528763e77e1f55b54b6674c890a9d02302ee8 Reviewed-on: https://code.wireshark.org/review/13691 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'fileset.c')
1 files changed, 2 insertions, 2 deletions
diff --git a/fileset.c b/fileset.c
index 60bb6d5..b1e636c 100644
--- a/fileset.c
+++ b/fileset.c
@@ -275,8 +275,8 @@ fileset_add_dir(const char *fname, void *window)
/* get (convert) directory name, but don't touch the given string */
- fname_dup = get_dirname(g_strdup(fname));
- dirname = g_string_new(fname_dup);
+ fname_dup = g_strdup(fname);
+ dirname = g_string_new(get_dirname(fname_dup));
set.dirname = g_strdup(dirname->str);