-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from alltilla/filterx-leak-fixes
filterx: fix some memory leaks
- Loading branch information
Showing
4 changed files
with
25 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (c) 2024 Attila Szakacs | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 Attila Szakacs <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
|
@@ -146,13 +147,15 @@ filterx_compound_expr_add(FilterXExpr *s, FilterXExpr *expr) | |
g_ptr_array_add(self->exprs, expr); | ||
} | ||
|
||
/* Takes reference of expr_list */ | ||
void | ||
filterx_compound_expr_add_list(FilterXExpr *s, GList *expr_list) | ||
{ | ||
for (GList *elem = expr_list; elem; elem = elem->next) | ||
{ | ||
filterx_compound_expr_add(s, elem->data); | ||
} | ||
g_list_free(expr_list); | ||
} | ||
|
||
FilterXExpr * | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (c) 2024 Attila Szakacs | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 Attila Szakacs <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
|
@@ -96,14 +97,15 @@ _create_container_free(FilterXExpr *s) | |
filterx_expr_free_method(s); | ||
} | ||
|
||
/* Takes reference of g and fillable_parent */ | ||
FilterXExpr * | ||
filterx_generator_create_container_new(FilterXExpr *g, FilterXExpr *fillable_parent) | ||
{ | ||
FilterXExprGeneratorCreateContainer *self = g_new0(FilterXExprGeneratorCreateContainer, 1); | ||
|
||
filterx_expr_init_instance(&self->super); | ||
self->generator = (FilterXExprGenerator *) filterx_expr_ref(g); | ||
self->fillable_parent = filterx_expr_ref(fillable_parent); | ||
self->generator = (FilterXExprGenerator *) g; | ||
self->fillable_parent = fillable_parent; | ||
self->super.eval = _create_container_eval; | ||
self->super.free_fn = _create_container_free; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/* | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 Attila Szakacs <[email protected]> | ||
* Copyright (c) 2023 Balazs Scheidler <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
|
@@ -220,7 +222,9 @@ generator_assignment | |
filterx_generator_set_fillable($5, filterx_getattr_new(filterx_expr_ref($1), filterx_config_frozen_string(configuration, $3))); | ||
|
||
$$ = filterx_compound_expr_new_va(TRUE, | ||
filterx_setattr_new($1, filterx_config_frozen_string(configuration, $3), filterx_generator_create_container_new($5, $1)), | ||
filterx_setattr_new(filterx_expr_ref($1), | ||
filterx_config_frozen_string(configuration, $3), | ||
filterx_generator_create_container_new(filterx_expr_ref($5), $1)), | ||
$5, | ||
NULL | ||
); | ||
|
@@ -231,7 +235,9 @@ generator_assignment | |
filterx_generator_set_fillable($6, filterx_get_subscript_new(filterx_expr_ref($1), filterx_expr_ref($3))); | ||
|
||
$$ = filterx_compound_expr_new_va(TRUE, | ||
filterx_set_subscript_new($1, $3, filterx_generator_create_container_new($6, $1)), | ||
filterx_set_subscript_new(filterx_expr_ref($1), | ||
$3, | ||
filterx_generator_create_container_new(filterx_expr_ref($6), $1)), | ||
$6, | ||
NULL | ||
); | ||
|
@@ -242,7 +248,9 @@ generator_assignment | |
filterx_generator_set_fillable($5, filterx_get_subscript_new(filterx_expr_ref($1), minus_one)); | ||
|
||
$$ = filterx_compound_expr_new_va(TRUE, | ||
filterx_set_subscript_new($1, NULL, filterx_generator_create_container_new($5, $1)), | ||
filterx_set_subscript_new(filterx_expr_ref($1), | ||
NULL, | ||
filterx_generator_create_container_new(filterx_expr_ref($5), $1)), | ||
$5, | ||
NULL | ||
); | ||
|
@@ -255,7 +263,7 @@ generator_assignment | |
|
||
filterx_generator_set_fillable($3, filterx_expr_ref($1)); | ||
$$ = filterx_compound_expr_new_va(TRUE, | ||
filterx_assign_new($1, filterx_generator_create_container_new($3, json_func)), | ||
filterx_assign_new($1, filterx_generator_create_container_new(filterx_expr_ref($3), json_func)), | ||
$3, | ||
NULL | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/* | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 Attila Szakacs <[email protected]> | ||
* Copyright (c) 2023 Balazs Scheidler <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
|
@@ -224,15 +226,15 @@ _unmarshal_repr(const gchar *repr, gssize repr_len, LogMessageValueType t) | |
return NULL; | ||
} | ||
|
||
/* NOTE: calling map_to_json() on a FilterXMessageBase is less than ideal as | ||
/* NOTE: calling map_to_json() on a FilterXMessageValue is less than ideal as | ||
* we would unmarshal the value and then drop the result. The expectation | ||
* is that the caller would explicitly unmarshall first, cache the result | ||
* and call map_to_json on the unmarshalled object. | ||
*/ | ||
static gboolean | ||
_map_to_json(FilterXObject *s, struct json_object **jso, FilterXObject **assoc_object) | ||
{ | ||
FilterXObject *unmarshalled_object = filterx_object_unmarshal(filterx_object_ref(s)); | ||
FilterXObject *unmarshalled_object = filterx_object_unmarshal(s); | ||
|
||
if (unmarshalled_object) | ||
{ | ||
|