aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-10-18 14:22:13 +0100
committerJoão Valverde <j@v6e.pt>2021-10-18 14:22:13 +0100
commit3562d76d5af0124da5255479f1ef825685a4d455 (patch)
tree7499a52bfca778cbdcebcb6525f1926e64a3e5e9
parente8800ff3c49e0b8a7a04d06ea68a39a16bab778f (diff)
dfilter: Fix memory leak in stnode_tostr()
Fixes #17661.
-rw-r--r--epan/dfilter/syntax-tree.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/epan/dfilter/syntax-tree.c b/epan/dfilter/syntax-tree.c
index 1bd88f88fd..162ddc5a9b 100644
--- a/epan/dfilter/syntax-tree.c
+++ b/epan/dfilter/syntax-tree.c
@@ -261,22 +261,26 @@ stnode_set_inside_parens(stnode_t *node, gboolean inside)
static char *
_node_tostr(stnode_t *node, gboolean pretty)
{
- const char *s;
+ char *s, *repr;
if (node->type->func_tostr == NULL)
- s = "FIXME";
+ s = g_strdup("FIXME");
else
s = node->type->func_tostr(node->data, pretty);
if (pretty)
- return g_strdup(s);
+ return s;
- return g_strdup_printf("%s<%s>", stnode_type_name(node), s);
+ repr = g_strdup_printf("%s<%s>", stnode_type_name(node), s);
+ g_free(s);
+ return repr;
}
const char *
stnode_tostr(stnode_t *node, gboolean pretty)
{
+ ws_assert_magic(node, STNODE_MAGIC);
+
if (pretty && node->repr_display != NULL)
return node->repr_display;