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) ```
This commit is contained in:
parent
2f51b2352d
commit
719f5f971d
5
tshark.c
5
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue