diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp index 84090c8580..91df0bd9b2 100644 --- a/libdnf/dnf-context.cpp +++ b/libdnf/dnf-context.cpp @@ -143,7 +143,7 @@ typedef struct gchar *install_root; gchar *source_root; gchar *rpm_verbosity; - gchar **native_arches; + gchar **native_arches{NULL}; gchar *http_proxy; gchar *user_agent; gchar *arch; @@ -2177,13 +2177,15 @@ dnf_context_setup(DnfContext *context, (void) dnf_context_get_base_arch(context); /* find all the native archs */ - priv->native_arches = g_new0(gchar *, MAX_NATIVE_ARCHES); - for (i = 0; arch_map[i].base != NULL; i++) { - if (g_strcmp0(arch_map[i].base, priv->base_arch) == 0) { - for (j = 0; arch_map[i].native[j] != NULL; j++) - priv->native_arches[j] = g_strdup(arch_map[i].native[j]); - priv->native_arches[j++] = g_strdup("noarch"); - break; + if (!priv->native_arches) { + priv->native_arches = g_new0(gchar *, MAX_NATIVE_ARCHES); + for (i = 0; arch_map[i].base != NULL; i++) { + if (g_strcmp0(arch_map[i].base, priv->base_arch) == 0) { + for (j = 0; arch_map[i].native[j] != NULL; j++) + priv->native_arches[j] = g_strdup(arch_map[i].native[j]); + priv->native_arches[j++] = g_strdup("noarch"); + break; + } } } diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp index 742af560d2..f9d774f0ff 100644 --- a/libdnf/dnf-repo.cpp +++ b/libdnf/dnf-repo.cpp @@ -228,7 +228,8 @@ dnf_repo_get_public_keys(DnfRepo *repo) for (char **iter = priv->gpgkeys; iter && *iter; iter++) { const char *key = *iter; g_autofree gchar *key_bn = g_path_get_basename(key); - g_ptr_array_add(ret, g_build_filename(priv->location, key_bn, NULL)); + g_autofree gchar *key_filename = g_build_filename(priv->location, key_bn, NULL); + g_ptr_array_add(ret, key_filename); } g_ptr_array_add(ret, NULL); return (gchar**)g_ptr_array_free(static_cast(g_steal_pointer(&ret)), FALSE); @@ -1044,7 +1045,8 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, GError **error) cache_path = g_build_filename(dnf_context_get_cache_dir(priv->context), cache_file_name, NULL); if (priv->packages == NULL) { - dnf_repo_set_packages(repo, g_build_filename(cache_path, "packages", NULL)); + g_autofree gchar *packages_path = g_build_filename(cache_path, "packages", NULL); + dnf_repo_set_packages(repo, packages_path); } if (priv->location == NULL) { dnf_repo_set_location(repo, cache_path);