From 605c7ee87bca36d98d212bee73c6509c2ab8d182 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Wed, 18 Jan 2017 22:46:55 +0000 Subject: [PATCH] Fix compiler warnings with uninitialised cleanup pointers This change fixes GCC compiler warnings where a cleanup function was specified on an uninitialised pointer, which in the view of GCC could result in an errornous free of uninitialised memory, if the functions that initialise them do not return NULL. Signed-off-by: Ikey Doherty --- app/flatpak-builtins-list.c | 2 +- app/flatpak-main.c | 4 ++-- builder/builder-main.c | 2 +- builder/builder-source-bzr.c | 2 +- builder/builder-source.c | 2 +- common/flatpak-dir.c | 2 +- common/flatpak-run.c | 4 ++-- permission-store/xdg-permission-store.c | 2 +- system-helper/flatpak-system-helper.c | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/flatpak-builtins-list.c b/app/flatpak-builtins-list.c index 17c1f215..600001df 100644 --- a/app/flatpak-builtins-list.c +++ b/app/flatpak-builtins-list.c @@ -210,7 +210,7 @@ print_table_for_refs (gboolean print_apps, GPtrArray* refs_array, const char *ar if (strcmp (parts[0], "app") == 0) { - g_autofree char *current; + g_autofree char *current = NULL; current = flatpak_dir_current_ref (dir, parts[1], cancellable); if (current && strcmp (ref, current) == 0) diff --git a/app/flatpak-main.c b/app/flatpak-main.c index e4b3a2e5..56e5c358 100644 --- a/app/flatpak-main.c +++ b/app/flatpak-main.c @@ -174,7 +174,7 @@ flatpak_usage (FlatpakCommand *commands, gboolean is_error) { GOptionContext *context; - g_autofree char *help; + g_autofree char *help = NULL; context = flatpak_option_context_new_with_commands (commands); @@ -344,7 +344,7 @@ flatpak_run (int argc, if (!command->fn) { GOptionContext *context; - g_autofree char *help; + g_autofree char *help = NULL; context = flatpak_option_context_new_with_commands (commands); diff --git a/builder/builder-main.c b/builder/builder-main.c index 27b7d5fa..9b3ad652 100644 --- a/builder/builder-main.c +++ b/builder/builder-main.c @@ -200,7 +200,7 @@ main (int argc, g_autoptr(GFileEnumerator) dir_enum2 = NULL; GFileInfo *next = NULL; const char *platform_id = NULL; - g_autofree char **orig_argv; + g_autofree char **orig_argv = NULL; gboolean is_run = FALSE; gboolean is_show_deps = FALSE; gboolean app_dir_is_empty = FALSE; diff --git a/builder/builder-source-bzr.c b/builder/builder-source-bzr.c index a261ca87..08e3ca79 100644 --- a/builder/builder-source-bzr.c +++ b/builder/builder-source-bzr.c @@ -245,7 +245,7 @@ builder_source_bzr_checksum (BuilderSource *source, BuilderContext *context) { BuilderSourceBzr *self = BUILDER_SOURCE_BZR (source); - g_autofree char *current_commit; + g_autofree char *current_commit = NULL; g_autoptr(GError) error = NULL; diff --git a/builder/builder-source.c b/builder/builder-source.c index 656b9a15..0e0dfcef 100644 --- a/builder/builder-source.c +++ b/builder/builder-source.c @@ -264,7 +264,7 @@ builder_source_extract (BuilderSource *self, { BuilderSourceClass *class; - g_autoptr(GFile) real_dest; + g_autoptr(GFile) real_dest = NULL; class = BUILDER_SOURCE_GET_CLASS (self); diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index b6c981ac..3dee91d6 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -2603,7 +2603,7 @@ flatpak_dir_list_refs (FlatpakDir *self, { gboolean ret = FALSE; - g_autoptr(GFile) base; + g_autoptr(GFile) base = NULL; g_autoptr(GFileEnumerator) dir_enum = NULL; g_autoptr(GFileInfo) child_info = NULL; GError *temp_error = NULL; diff --git a/common/flatpak-run.c b/common/flatpak-run.c index dfc2335f..92c9908e 100644 --- a/common/flatpak-run.c +++ b/common/flatpak-run.c @@ -563,7 +563,7 @@ get_xdg_dir_from_string (const char *filesystem, { char *slash; const char *rest; - g_autofree char *prefix; + g_autofree char *prefix = NULL; const char *dir = NULL; gsize len; @@ -597,7 +597,7 @@ get_xdg_user_dir_from_string (const char *filesystem, { char *slash; const char *rest; - g_autofree char *prefix; + g_autofree char *prefix = NULL; gsize len; slash = strchr (filesystem, '/'); diff --git a/permission-store/xdg-permission-store.c b/permission-store/xdg-permission-store.c index 12ae35b7..d6f14834 100644 --- a/permission-store/xdg-permission-store.c +++ b/permission-store/xdg-permission-store.c @@ -329,7 +329,7 @@ handle_set (XdgPermissionStore *object, g_variant_iter_init (&iter, app_permissions); while ((child = g_variant_iter_next_value (&iter))) { - g_autoptr(FlatpakDbEntry) old_entry; + g_autoptr(FlatpakDbEntry) old_entry = NULL; const char *child_app_id; g_autofree const char **permissions; diff --git a/system-helper/flatpak-system-helper.c b/system-helper/flatpak-system-helper.c index 47fe0072..23aa66dc 100644 --- a/system-helper/flatpak-system-helper.c +++ b/system-helper/flatpak-system-helper.c @@ -663,7 +663,7 @@ flatpak_authorize_method_handler (GDBusInterfaceSkeleton *interface, if (action) { - g_autoptr(AutoPolkitAuthorizationResult) result; + g_autoptr(AutoPolkitAuthorizationResult) result = NULL; g_autoptr(GError) error = NULL; result = polkit_authority_check_authorization_sync (authority, subject,