From 8899e006aab3e0831214d187596eef450b5e21b7 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 3 Feb 2016 18:28:46 +0100 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- wireshark-qt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wireshark-qt.cpp') diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index 1eaff2c89a..d4441e2c55 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -1410,8 +1410,8 @@ int main(int argc, char *argv[]) if (global_capture_opts.save_file != NULL) { /* Save the directory name for future file dialogs. */ /* (get_dirname overwrites filename) */ - gchar *s = get_dirname(g_strdup(global_capture_opts.save_file)); - set_last_open_dir(s); + gchar *s = g_strdup(global_capture_opts.save_file); + set_last_open_dir(get_dirname(s)); g_free(s); } /* "-k" was specified; start a capture. */ -- cgit v1.2.3