dfilter: Fix memory leak in stnode_tostr()

Fixes #17661.
This commit is contained in:
João Valverde 2021-10-18 14:22:13 +01:00
parent e8800ff3c4
commit 3562d76d5a
1 changed files with 8 additions and 4 deletions

View File

@ -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;