dir: Consistently initialize g_autofree variables

All g_autofree and g_autoptr variables should be initialized, either
with a value or NULL, and some gcc versions warn if they are not.

This particular instance was harmless, because we initialized regexp
to either NULL or a valid non-NULL value as the first statement of the
function, so there was no way to return before regexp was initialized;
but if we introduced an early-return such as a g_return_val_if_fail
before the current first statement, then that early return would have
caused uninitialized stack contents to be freed, likely resulting in a
crash.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2023-03-20 11:18:43 +00:00
parent ec6ca9b6a6
commit 43085c0e2a

View File

@@ -4402,7 +4402,7 @@ flatpak_dir_config_append_pattern (FlatpakDir *self,
GError **error)
{
g_autoptr(GPtrArray) patterns = flatpak_dir_get_config_patterns (self, key);
g_autofree char *regexp;
g_autofree char *regexp = NULL;
gboolean already_present;
g_autofree char *merged_patterns = NULL;