diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-07-15 01:31:16 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-07-15 08:31:55 +0000 |
commit | 996dcc038dea197924285a6717b522a57f95fd65 (patch) | |
tree | 064ca576e610eb4ce34f290235dcd1d719368a8b /wiretap/erf.c | |
parent | ced207150542f59f395fc4052d8a7cdfba67effa (diff) | |
download | wireshark-996dcc038dea197924285a6717b522a57f95fd65.tar.gz |
Do a deep copy in wtap_block_add_custom_option().
That way, we don't have to worry about multiple instances of an option
pointing to the same data. and having to worry about freeing data that's
pointed to by another instance.
Change-Id: I3470a9eebf346023713fd0d6ff2451d727c25089
Reviewed-on: https://code.wireshark.org/review/16471
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/erf.c')
-rw-r--r-- | wiretap/erf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/wiretap/erf.c b/wiretap/erf.c index e694ade9b2..8d63fb2f51 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -1561,6 +1561,7 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo case ERF_META_TAG_filter: if_filter.if_filter_str = g_strndup((gchar*) tag.value, tag.length); wtap_block_add_custom_option(int_data, OPT_IDB_FILTER, &if_filter, sizeof if_filter); + g_free(if_filter.if_filter_str); if_info->set_flags.filter = 1; break; default: @@ -1583,7 +1584,7 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo */ if (state->if_map->module_filter_str && !if_info->set_flags.filter) { /* Duplicate because might use with multiple interfaces */ - if_filter.if_filter_str = g_strdup(state->if_map->module_filter_str); + if_filter.if_filter_str = state->if_map->module_filter_str; wtap_block_add_custom_option(int_data, OPT_IDB_FILTER, &if_filter, sizeof if_filter); /* * Don't set flag because stream is more specific than module. Interface @@ -1727,6 +1728,7 @@ static int populate_stream_info(erf_t *erf_priv _U_, wtap *wth, union wtap_pseud if (!if_info->set_flags.filter) { if_filter.if_filter_str = g_strndup((gchar*) tag.value, tag.length); wtap_block_add_custom_option(int_data, OPT_IDB_FILTER, &if_filter, sizeof if_filter); + g_free(if_filter.if_filter_str); if_info->set_flags.filter = 1; } break; |