Skip to content

Commit

Permalink
Fix a crash when repoId not found in loaded conf gkeyFile (RhBug:1946…
Browse files Browse the repository at this point in the history
…024)

The crash was caused by missing return value check.

This can happen for example when using a bootable iso media which is
missing the [media] section in .treeinfo.

= changelog =
msg: Fix a crash when [media] section in .treeinfo is missing for bootable media
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1946024
  • Loading branch information
kontura authored and Conan-Kudo committed Apr 15, 2021
1 parent 9a0e175 commit be66d09
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libdnf/dnf-repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,13 @@ dnf_repo_conf_from_gkeyfile(libdnf::ConfigRepo &config, const char *repoId, GKey
// Reset to the initial state before reloading the configuration.
dnf_repo_conf_reset(config);

g_auto(GStrv) keys = g_key_file_get_keys(gkeyFile, repoId, NULL, NULL);
g_autoptr(GError) error_local = NULL;
g_auto(GStrv) keys = g_key_file_get_keys(gkeyFile, repoId, NULL, &error_local);
if (keys == NULL) {
g_debug("Failed to load configuration for repo id \"%s\": %s", repoId, error_local->message);
return;
}

for (auto it = keys; *it != NULL; ++it) {
auto key = *it;
g_autofree gchar *str = g_key_file_get_value(gkeyFile, repoId, key, NULL);
Expand Down

0 comments on commit be66d09

Please sign in to comment.