BACKPORT: FROMLIST: Fix a depgraph crash with useoldpkg and subslot bumps

This resolves a "list index out of range" error that could happen with
when a package's subslot is bumped and --useoldpkg is used.

Due to the subslot bump, the code will filter matched_packages to
only contain the latest version. However, this didn't update
matched_oldpkg, which would now contain stale packages and cause logic
errors.

Fix this by filtering matched_oldpkg again before its use.

(cherry picked from commit 719d8a5100bae64b69894af9fb07131e59aafe3e)

BUG=b:339628861
TEST=Bump abseil-cpp subslot and run UpdateSdk through chromite.

Link: https://github.com/gentoo/portage/pull/1322
Change-Id: Ia9a68e76266f7d8c5f64da834aba37ae0fb7e00c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/portage_tool/+/5545478
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Tim Bain <tbain@google.com>
Commit-Queue: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
1 file changed