From ceda9755dea78a74422aac06fdf3d83ea151dd46 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 6 Aug 2020 14:03:54 +0100 Subject: [PATCH] guri: Clear return values on error from g_uri_params_iter_next() This reduces the chance of the caller accidentally double-freeing or use-after-free-ing something. Signed-off-by: Philip Withnall --- glib/guri.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/glib/guri.c b/glib/guri.c index f0944a050..905130255 100644 --- a/glib/guri.c +++ b/glib/guri.c @@ -1973,6 +1973,12 @@ g_uri_params_iter_next (GUriParamsIter *iter, g_return_val_if_fail (iter != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + /* Pre-clear these in case of failure or finishing. */ + if (attribute) + *attribute = NULL; + if (value) + *value = NULL; + if (ri->attr >= ri->end) return FALSE;