From 33c471c88381d0ba77360f443d2a1d930574d878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Sun, 20 Oct 2024 12:43:34 +0200 Subject: [PATCH] filterx-unset-empties: fix use-after-free MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- lib/filterx/func-unset-empties.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/lib/filterx/func-unset-empties.c b/lib/filterx/func-unset-empties.c index 4806fd2bc..2a8e1321d 100644 --- a/lib/filterx/func-unset-empties.c +++ b/lib/filterx/func-unset-empties.c @@ -173,15 +173,6 @@ _process_dict(FilterXFunctionUnsetEmpties *self, FilterXObject *obj) return success; } -/* Takes reference of obj. */ -static FilterXObject * -_eval_on_dict(FilterXFunctionUnsetEmpties *self, FilterXObject *obj) -{ - gboolean success = _process_dict(self, obj); - filterx_object_unref(obj); - return success ? filterx_boolean_new(TRUE) : NULL; -} - static gboolean _process_list(FilterXFunctionUnsetEmpties *self, FilterXObject *obj) { @@ -232,15 +223,6 @@ _process_list(FilterXFunctionUnsetEmpties *self, FilterXObject *obj) return TRUE; } -/* Takes reference of obj. */ -static FilterXObject * -_eval_on_list(FilterXFunctionUnsetEmpties *self, FilterXObject *obj) -{ - gboolean success = _process_list(self, obj); - filterx_object_unref(obj); - return success ? filterx_boolean_new(TRUE) : NULL; -} - static FilterXObject * _eval(FilterXExpr *s) { @@ -255,10 +237,18 @@ _eval(FilterXExpr *s) FilterXObject *obj_unwrapped = filterx_ref_unwrap_rw(obj); if (filterx_object_is_type(obj_unwrapped, &FILTERX_TYPE_NAME(dict))) - return _eval_on_dict(self, obj_unwrapped); + { + gboolean success = _process_dict(self, obj_unwrapped); + filterx_object_unref(obj); + return success ? filterx_boolean_new(TRUE) : NULL; + } if (filterx_object_is_type(obj_unwrapped, &FILTERX_TYPE_NAME(list))) - return _eval_on_list(self, obj_unwrapped); + { + gboolean success = _process_list(self, obj_unwrapped); + filterx_object_unref(obj); + return success ? filterx_boolean_new(TRUE) : NULL; + } filterx_eval_push_error("Object must be dict or list. " FILTERX_FUNC_UNSET_EMPTIES_USAGE, s, obj); filterx_object_unref(obj);