Skip to content

Commit

Permalink
dir: Consistently initialize g_autofree variables
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
smcv committed Mar 20, 2023
1 parent ec6ca9b commit 43085c0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion common/flatpak-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 43085c0

Please sign in to comment.