Skip to content

Commit

Permalink
Merge pull request #300 from alltilla/leak-fixes
Browse files Browse the repository at this point in the history
Various memory leak fixes
  • Loading branch information
bazsi authored Sep 20, 2024
2 parents fe6cfcc + f5d0fb3 commit 5158c53
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/filterx/filterx-grammar.ym
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ generator_casted_assignment
NULL
);
free($3);
free($5);
}
| expr '[' expr ']' KW_ASSIGN func_name '(' expr_generator ')'
{
Expand Down Expand Up @@ -355,7 +356,7 @@ declaration

filterx_generator_set_fillable($4, filterx_expr_ref($2));
$$ = filterx_compound_expr_new_va(TRUE,
filterx_assign_new($2, filterx_generator_create_container_new($4, json_func)),
filterx_assign_new($2, filterx_generator_create_container_new(filterx_expr_ref($4), json_func)),
$4,
NULL
);
Expand Down
4 changes: 4 additions & 0 deletions lib/logsource.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,8 @@ _set_metric_options(LogSource *self, const gchar *stats_id, StatsClusterKeyBuild
self->stats_id, instance_name);
stats_cluster_key_builder_set_legacy_alias_name(self->metrics.stats_kb, "processed");
stats_cluster_key_builder_add_label(self->metrics.stats_kb, stats_cluster_label("id", self->stats_id));
if (self->metrics.recvd_messages_key)
stats_cluster_key_free(self->metrics.recvd_messages_key);
self->metrics.recvd_messages_key = stats_cluster_key_builder_build_single(self->metrics.stats_kb);
}
stats_cluster_key_builder_pop(self->metrics.stats_kb);
Expand All @@ -735,6 +737,8 @@ _set_metric_options(LogSource *self, const gchar *stats_id, StatsClusterKeyBuild
{
stats_cluster_key_builder_set_name(self->metrics.stats_kb, "input_event_bytes_total");;
stats_cluster_key_builder_add_label(self->metrics.stats_kb, stats_cluster_label("id", self->stats_id));
if (self->metrics.recvd_bytes_key)
stats_cluster_key_free(self->metrics.recvd_bytes_key);
self->metrics.recvd_bytes_key = stats_cluster_key_builder_build_single(self->metrics.stats_kb);
}
stats_cluster_key_builder_pop(self->metrics.stats_kb);
Expand Down
9 changes: 9 additions & 0 deletions lib/logthrdest/logthrdestdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,15 @@ _unregister_driver_stats(LogThreadedDestDriver *self)
stats_cluster_key_free(self->metrics.processed_sc_key);
self->metrics.processed_sc_key = NULL;
}

if (self->metrics.output_event_retries_sc_key)
{
stats_unregister_counter(self->metrics.output_event_retries_sc_key, SC_TYPE_SINGLE_VALUE,
&self->metrics.output_event_retries);

stats_cluster_key_free(self->metrics.output_event_retries_sc_key);
self->metrics.output_event_retries_sc_key = NULL;
}
}
stats_unlock();
}
Expand Down
1 change: 1 addition & 0 deletions lib/metrics/dyn-metrics-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ dyn_metrics_template_clone(DynMetricsTemplate *self, GlobalConfig *cfg)
LabelTemplate *label_template = (LabelTemplate *) elem->data;
cloned->label_templates = g_list_append(cloned->label_templates, label_template_clone(label_template));
}
value_pairs_unref(cloned->vp);
cloned->vp = value_pairs_ref(self->vp);
return cloned;
}
2 changes: 2 additions & 0 deletions lib/pragma-grammar.ym
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ requires_stmt
evt_tag_str("details", $3 ? : "none"),
cfg_lexer_format_location_tag(lexer,&@1));
free($2);
free($3);
PRAGMA_ERROR();
}
else
Expand All @@ -201,6 +202,7 @@ requires_stmt
}
}
free($2);
free($3);
}
;

Expand Down
1 change: 1 addition & 0 deletions modules/appmodel/transformation.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ transformation_step_free(TransformationStep *self)
{
g_free(self->name);
g_free(self->expr);
g_free(self);
}

/* TransformationBlock: named list of steps */
Expand Down
1 change: 1 addition & 0 deletions modules/metrics-probe/metrics-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ _clone(LogPipe *s)
MetricsProbe *cloned = (MetricsProbe *) metrics_probe_new(s->cfg);

log_parser_clone_settings(&self->super, &cloned->super);
dyn_metrics_template_free(cloned->metrics_template);
cloned->metrics_template = dyn_metrics_template_clone(self->metrics_template, s->cfg);

metrics_probe_set_increment_template(&cloned->super, self->increment_template);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TestLangCompleter(CompleterTestCase):
'PARTIAL_TOKEN': ChoiceCompleter(("tokenP-a", "tokenP-b"), prefix='@', suffix='')
}

# pylint: disable=arguments-differ,too-many-arguments
# pylint: disable=arguments-differ,too-many-arguments,too-many-positional-arguments
def _construct_completer(self, expected_token=None, expected_tokens=None,
replaced_token=None, replaced_token_pos=-1,
completers=None, prefix="<!--"):
Expand Down

0 comments on commit 5158c53

Please sign in to comment.