Skip to content

Commit

Permalink
[context] Fix: dnf_package_is_installonly (RhBug:1928056)
Browse files Browse the repository at this point in the history
The previous implementation of "dnf_package_is_installonly" incorrectly used
the "dnf_context_get_installonly_pkgs" function. Instead of the required
argument - a pointer to "context" - it passed NULL.
The old version of "dnf_context_get_installonly_pkgs" with NULL happened
to work even though according to the documentation it requires a pointer
to "context". But, after its update, the problem came.

https://bugzilla.redhat.com/show_bug.cgi?id=1928056
  • Loading branch information
jrohel authored and j-mracek committed Feb 12, 2021
1 parent bd68ed9 commit 1c0627a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions libdnf/dnf-package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <memory>

#include "catch-error.hpp"
#include "dnf-context.hpp"
#include "dnf-package.h"
#include "dnf-types.h"
#include "dnf-utils.h"
Expand Down Expand Up @@ -655,15 +656,13 @@ dnf_package_is_downloaded(DnfPackage *pkg)
gboolean
dnf_package_is_installonly(DnfPackage *pkg)
{
const gchar **installonly_pkgs;
const gchar *pkg_name;
guint i;

installonly_pkgs = dnf_context_get_installonly_pkgs(NULL);
pkg_name = dnf_package_get_name(pkg);
for (i = 0; installonly_pkgs[i] != NULL; i++) {
if (g_strcmp0(pkg_name, installonly_pkgs[i]) == 0)
return TRUE;
if (auto * pkg_name = dnf_package_get_name(pkg)) {
auto & mainConf = libdnf::getGlobalMainConfig();
for (auto & inst_only_pkg_name : mainConf.installonlypkgs().getValue()) {
if (inst_only_pkg_name == pkg_name) {
return TRUE;
}
}
}
return FALSE;
}
Expand Down

0 comments on commit 1c0627a

Please sign in to comment.