Skip to content

Commit

Permalink
filterAdvisory: match installed_solvables sort with lower_bound (RhBu…
Browse files Browse the repository at this point in the history
…g:2212838)

`std::lower_bound` expects that the range it operates on is sorted by
the provided comparator.

`lower_bound()` is used on `installed_solvables` twice, first with
comparator `NameSolvableComparator` and later with
`SolvableCompareAdvisoryPkgNameArch` to cover both we need to sort
`installed_solvables` by name and arch.

Otherwise this can lead to problems if multiple architectures of a pkg
are installed.

For: https://bugzilla.redhat.com/show_bug.cgi?id=2212838
  • Loading branch information
kontura authored and jrohel committed Oct 6, 2023
1 parent 31e7378 commit d138dbf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libdnf/sack/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1903,7 +1903,7 @@ Query::Impl::filterAdvisory(const Filter & f, Map *m, int keyname)
while ((installed_id = installed.pImpl->result->next(installed_id)) != -1) {
installed_solvables.push_back(pool_id2solvable(pool, installed_id));
}
std::sort(installed_solvables.begin(), installed_solvables.end(), NameSolvableComparator);
std::sort(installed_solvables.begin(), installed_solvables.end(), NameArchSolvableComparator);

Query obsoletes(sack, ExcludeFlags::IGNORE_EXCLUDES);
obsoletes.addFilter(HY_PKG, HY_EQ, resultPset);
Expand Down

0 comments on commit d138dbf

Please sign in to comment.