From e83f1061d06096470c03efce047d134b85b4b99e Mon Sep 17 00:00:00 2001
From: Julian Andres Klode <julian.klode@canonical.com>
Date: Thu, 26 Jul 2018 10:39:47 +0800
Subject: [PATCH 2/2] aptcc: Use installed version to determine garbage

Some garbage might not have a candidate available; for example, if
the package is pinned to -1.
---
 backends/aptcc/apt-intf.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/backends/aptcc/apt-intf.cpp b/backends/aptcc/apt-intf.cpp
index cb6f1cce7..3bec90402 100644
--- a/backends/aptcc/apt-intf.cpp
+++ b/backends/aptcc/apt-intf.cpp
@@ -2160,7 +2160,7 @@ bool AptIntf::runTransaction(const PkgList &install, const PkgList &remove, cons
     PkgList initial_garbage;
     if (autoremove) {
         for (pkgCache::PkgIterator pkg = (*m_cache)->PkgBegin(); ! pkg.end(); ++pkg) {
-            const pkgCache::VerIterator &ver = m_cache->findCandidateVer(pkg);
+            const pkgCache::VerIterator &ver = pkg.CurrentVer();
             if (!ver.end() && m_cache->isGarbage(pkg))
                 initial_garbage.push_back(ver);
         }
@@ -2209,7 +2209,7 @@ bool AptIntf::runTransaction(const PkgList &install, const PkgList &remove, cons
     // Remove new garbage that is created
     if (autoremove) {
         for (pkgCache::PkgIterator pkg = (*m_cache)->PkgBegin(); ! pkg.end(); ++pkg) {
-            const pkgCache::VerIterator &ver = m_cache->findCandidateVer(pkg);
+            const pkgCache::VerIterator &ver = pkg.CurrentVer();
             if (!ver.end() && !initial_garbage.contains(pkg) && m_cache->isGarbage(pkg))
                 m_cache->tryToRemove (Fix, ver);
         }
-- 
2.17.1

