summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2025-05-25 12:25:21 +0200
committerJulian Andres Klode <jak@debian.org>2025-05-26 12:08:29 +0200
commit822c979d5e010e24e513875b608d1f68daaeced4 (patch)
tree1496e902554b11538685394c80c06512199bbeed
parent4f5b0fe1d6af3a5cce15636b9c5307438a9c2d9f (diff)
solver3: Handle failed assumption in Pop()
If an Assume() failed, we will have pushed the choices stack, but not actually pushed anything to the solved stack. This would cause a segmentation fault trying to read the referenced entry that doesn't actually exists, namely solved[solved.size()]. Handle this by exiting early as there's nothing to do except pop the entry back out of the array.
-rw-r--r--apt-pkg/solver3.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index b97e3b694..3e2f53a26 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -956,6 +956,13 @@ bool APT::Solver::Pop()
_error->Discard();
+ // Assume() actually failed to enqueue anything, abort here
+ if (choices.back() == solved.size())
+ {
+ choices.pop_back();
+ return true;
+ }
+
assert(choices.back() < solved.size());
int itemsToUndo = solved.size() - choices.back();
auto choice = solved[choices.back()].assigned;