Fixed memory leakage in col_cleanup.
Several fields in cinfo is allocated memory and must be freed here to avoid memory leakage when recreating the packet list. Do not allocate memory for col_expr[] as this points to static strings or other allocated strings. Change-Id: I840377e3c590b1a3e2a38e0537465a028041d1e9 Reviewed-on: https://code.wireshark.org/review/5137 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
64b8759fbb
commit
d58567bd78
|
@ -42,6 +42,7 @@
|
|||
#include <epan/strutil.h>
|
||||
#include <epan/emem.h>
|
||||
#include <epan/epan.h>
|
||||
#include <epan/dfilter/dfilter.h>
|
||||
|
||||
/* Allocate all the data structures for constructing column data, given
|
||||
the number of columns. */
|
||||
|
@ -77,6 +78,17 @@ col_setup(column_info *cinfo, const gint num_cols)
|
|||
void
|
||||
col_cleanup(column_info *cinfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cinfo->num_cols; i++) {
|
||||
g_free(cinfo->fmt_matx[i]);
|
||||
g_free(cinfo->col_title[i]);
|
||||
g_free(cinfo->col_custom_field[i]);
|
||||
dfilter_free(cinfo->col_custom_dfilter[i]);
|
||||
g_free(cinfo->col_buf[i]);
|
||||
g_free(cinfo->col_expr.col_expr_val[i]);
|
||||
}
|
||||
|
||||
g_free(cinfo->col_fmt);
|
||||
g_free(cinfo->fmt_matx);
|
||||
g_free(cinfo->col_first);
|
||||
|
|
|
@ -824,7 +824,7 @@ build_column_format_array(column_info *cinfo, const gint num_cols, const gboolea
|
|||
if(reset_fences)
|
||||
cinfo->col_fence[i] = 0;
|
||||
|
||||
cinfo->col_expr.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
||||
cinfo->col_expr.col_expr[i] = "";
|
||||
cinfo->col_expr.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue