From 822c979d5e010e24e513875b608d1f68daaeced4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 25 May 2025 12:25:21 +0200 Subject: 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. --- apt-pkg/solver3.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'apt-pkg/solver3.cc') 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; -- cgit v1.2.3-70-g09d2