aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorNardi Ivan <nardi.ivan@gmail.com>2021-04-02 16:31:49 +0200
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-05-13 04:43:49 +0000
commit719f5f971d581e3d14a623124bdb16311cbf2d99 (patch)
treef36dacbb385972ba3368cc5f16f9138a186c1bee /tshark.c
parent2f51b2352d9d3072ed181dad9842b0a7b89ebfae (diff)
tshark: fix a memory leak about display filter configuration
If the variable `dfilter' always points to malloc-ed memory, it should be easier to avoid any leaks. Leak: ``` Direct leak of 46 byte(s) in 1 object(s) allocated from: #0 0x7fadf5a67bc8 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144 #1 0x7fadd7ecbe98 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x57e98) #2 0x5556272dbfd5 in main /home/ivan/svnrepos/wireshark/tshark.c:1594 #3 0x7fadd71ed0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) ```
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tshark.c b/tshark.c
index e6d282546e..174028ec90 100644
--- a/tshark.c
+++ b/tshark.c
@@ -750,7 +750,7 @@ main(int argc, char *argv[])
volatile int in_file_type = WTAP_TYPE_AUTO;
gchar *volatile cf_name = NULL;
gchar *rfilter = NULL;
- gchar *dfilter = NULL;
+ gchar *volatile dfilter = NULL;
dfilter_t *rfcode = NULL;
dfilter_t *dfcode = NULL;
e_prefs *prefs_p;
@@ -1457,7 +1457,7 @@ main(int argc, char *argv[])
/* already processed; just ignore it now */
break;
case 'Y':
- dfilter = optarg;
+ dfilter = g_strdup(optarg);
break;
case 'z':
/* We won't call the init function for the stat this soon
@@ -2344,6 +2344,7 @@ clean_exit:
wtap_cleanup();
free_progdirs();
dfilter_free(dfcode);
+ g_free(dfilter);
return exit_status;
}