Follow: Use common follow_reset_stream
Instead of having FollowStreamDialog implement its own version of follow_reset_stream (that actually frees everything), fix up the resetting function in epan/follow to avoid leaks and call that.
This commit is contained in:
parent
3a50b6dac7
commit
56200e40f5
|
@ -149,54 +149,53 @@ gchar* follow_get_stat_tap_string(register_follow_t* follower)
|
|||
void
|
||||
follow_reset_stream(follow_info_t* info)
|
||||
{
|
||||
GList *cur;
|
||||
follow_record_t *follow_record;
|
||||
|
||||
info->bytes_written[0] = info->bytes_written[1] = 0;
|
||||
info->client_port = 0;
|
||||
info->server_port = 0;
|
||||
info->client_ip.type = FT_NONE;
|
||||
info->client_ip.len = 0;
|
||||
info->server_ip.type = FT_NONE;
|
||||
info->server_ip.len = 0;
|
||||
|
||||
free_address(&info->client_ip);
|
||||
free_address(&info->server_ip);
|
||||
|
||||
for (cur = info->payload; cur; cur = g_list_next(cur)) {
|
||||
follow_record = (follow_record_t *)cur->data;
|
||||
if(follow_record->data)
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
|
||||
g_free(follow_record);
|
||||
}
|
||||
g_list_free(info->payload);
|
||||
info->payload = NULL;
|
||||
|
||||
//Only TCP stream uses fragments
|
||||
for (cur = info->fragments[0]; cur; cur = g_list_next(cur)) {
|
||||
follow_record = (follow_record_t *)cur->data;
|
||||
if(follow_record->data) {
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
}
|
||||
g_free(follow_record);
|
||||
}
|
||||
for (cur = info->fragments[1]; cur; cur = g_list_next(cur)) {
|
||||
follow_record = (follow_record_t *)cur->data;
|
||||
if(follow_record->data) {
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
}
|
||||
g_free(follow_record);
|
||||
}
|
||||
info->fragments[0] = info->fragments[1] = NULL;
|
||||
info->seq[0] = info->seq[1] = 0;
|
||||
info->substream_id = SUBSTREAM_UNUSED;
|
||||
|
||||
g_free(info->filter_out_filter);
|
||||
info->filter_out_filter = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
follow_info_free(follow_info_t* follow_info)
|
||||
{
|
||||
GList *cur;
|
||||
follow_record_t *follow_record;
|
||||
|
||||
for (cur = follow_info->payload; cur; cur = g_list_next(cur)) {
|
||||
if(cur->data) {
|
||||
follow_record = (follow_record_t *)cur->data;
|
||||
if(follow_record->data)
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
|
||||
g_free(follow_record);
|
||||
}
|
||||
}
|
||||
g_list_free(follow_info->payload);
|
||||
|
||||
//Only TCP stream uses fragments
|
||||
for (cur = follow_info->fragments[0]; cur; cur = g_list_next(cur)) {
|
||||
follow_record = (follow_record_t *)cur->data;
|
||||
if(follow_record->data) {
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
}
|
||||
g_free(follow_record);
|
||||
}
|
||||
for (cur = follow_info->fragments[1]; cur; cur = g_list_next(cur)) {
|
||||
follow_record = (follow_record_t *)cur->data;
|
||||
if(follow_record->data) {
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
}
|
||||
g_free(follow_record);
|
||||
}
|
||||
|
||||
free_address(&follow_info->client_ip);
|
||||
free_address(&follow_info->server_ip);
|
||||
g_free(follow_info->filter_out_filter);
|
||||
follow_reset_stream(follow_info);
|
||||
g_free(follow_info);
|
||||
}
|
||||
|
||||
|
|
|
@ -193,7 +193,8 @@ WS_DLL_PUBLIC void follow_iterate_followers(wmem_foreach_func func, gpointer use
|
|||
*/
|
||||
WS_DLL_PUBLIC gchar* follow_get_stat_tap_string(register_follow_t* follower);
|
||||
|
||||
/** Clear counters, addresses and ports of follow_info_t
|
||||
/** Clear payload, fragments, counters, addresses, and ports of follow_info_t
|
||||
* Free everything except the follow_info_t structure itself
|
||||
*
|
||||
* @param info [in] follower info
|
||||
*/
|
||||
|
|
|
@ -472,41 +472,7 @@ void FollowStreamDialog::removeStreamControls()
|
|||
|
||||
void FollowStreamDialog::resetStream()
|
||||
{
|
||||
GList *cur;
|
||||
follow_record_t *follow_record;
|
||||
|
||||
filter_out_filter_.clear();
|
||||
for (cur = follow_info_.payload; cur; cur = gxx_list_next(cur)) {
|
||||
follow_record = gxx_list_data(follow_record_t *, cur);
|
||||
if (follow_record->data) {
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
}
|
||||
g_free(follow_record);
|
||||
}
|
||||
g_list_free(follow_info_.payload);
|
||||
|
||||
//Only TCP stream uses fragments
|
||||
for (cur = follow_info_.fragments[0]; cur; cur = gxx_list_next(cur)) {
|
||||
follow_record = gxx_list_data(follow_record_t *, cur);
|
||||
if (follow_record->data) {
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
}
|
||||
g_free(follow_record);
|
||||
}
|
||||
follow_info_.fragments[0] = Q_NULLPTR;
|
||||
for (cur = follow_info_.fragments[1]; cur; cur = gxx_list_next(cur)) {
|
||||
follow_record = gxx_list_data(follow_record_t *, cur);
|
||||
if (follow_record->data) {
|
||||
g_byte_array_free(follow_record->data, TRUE);
|
||||
}
|
||||
g_free(follow_record);
|
||||
}
|
||||
follow_info_.fragments[1] = Q_NULLPTR;
|
||||
|
||||
free_address(&follow_info_.client_ip);
|
||||
free_address(&follow_info_.server_ip);
|
||||
follow_info_.payload = Q_NULLPTR;
|
||||
follow_info_.client_port = 0;
|
||||
follow_reset_stream(&follow_info_);
|
||||
}
|
||||
|
||||
frs_return_t
|
||||
|
@ -904,8 +870,6 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index,
|
|||
}
|
||||
}
|
||||
|
||||
follow_reset_stream(&follow_info_);
|
||||
|
||||
/* Create a new filter that matches all packets in the TCP stream,
|
||||
and set the display filter entry accordingly */
|
||||
if (use_stream_index) {
|
||||
|
|
Loading…
Reference in New Issue