- fix package-pointer array memory leak in ResolveByKeepInternal()
         continue;
       
       // Restart again.
-      if (K == LastStop)
-        return _error->Error("Internal Error, pkgProblemResolver::ResolveByKeep is looping on package %s.",I.FullName(false).c_str());
+      if (K == LastStop) {
+          // I is an iterator based off our temporary package list,
+          // so copy the name we need before deleting the temporary list
+          std::string const LoopingPackage = I.FullName(false);
+          delete[] PList;
+          return _error->Error("Internal Error, pkgProblemResolver::ResolveByKeep is looping on package %s.", LoopingPackage.c_str());
+      }
       LastStop = K;
       K = PList - 1;
-   }   
+   }
 
+   delete[] PList;
    return true;
 }
                                                                        /*}}}*/
 
     - ensure pkgProblemResolver calls MarkDelete without FromUser set
       so that it can't overrule holds and the protection flag
 
+  [ Jonathan Thomas ]
+  * apt-pkg/algorithms.cc:
+    - fix package-pointer array memory leak in ResolveByKeepInternal()
+
  -- Jordi Mallach <jordi@debian.org>  Thu, 18 Oct 2012 23:30:46 +0200
 
 apt (0.9.7.6) unstable; urgency=low