don't pass invalid iterators to pkgProblemResolver
authorJeremy Roman <jbroman@csclub.uwaterloo.ca>
Sun, 12 Jan 2014 05:32:10 +0000 (00:32 -0500)
committerJeremy Roman <jbroman@csclub.uwaterloo.ca>
Sun, 12 Jan 2014 05:32:10 +0000 (00:32 -0500)
inapt.cc

index 7a6c056..9fea989 100644 (file)
--- a/inapt.cc
+++ b/inapt.cc
@@ -381,8 +381,12 @@ static void exec_actions(std::vector<inapt_package *> *final_actions) {
 
     if (cache->BrokenCount()) {
         pkgProblemResolver fix (cache);
-        for (vector<inapt_package *>::iterator i = final_actions->begin(); i < final_actions->end(); i++)
-            fix.Protect((*i)->pkg);
+        for (vector<inapt_package *>::iterator i = final_actions->begin(); i < final_actions->end(); i++) {
+            pkgCache::PkgIterator k = (*i)->pkg;
+            if (k.end())
+                continue;
+            fix.Protect(k);
+        }
         fix.Resolve();
 
         if (cache->BrokenCount()) {