Don't pass invalid iterators to pkgProblemResolver.

This was apparently the cause of the crashes I was experiencing on CSC hosts (we almost invariably have *some* package with an error when I try to run inapt).

I'm not super-happy with this fix (I think that refactoring the rest of the code might make this kind of error less likely), but this is a fairly straightforward patch consistent with how we avoid crashing on bad iterators above, and should at least make this problem go away.