Don't access reference to a vector after pop_back

This is undefined behavior. Found by asan's detect_container_overflow.
This commit is contained in:
Benjamin Kramer 2020-04-07 23:06:59 +02:00
parent 1834ad4a69
commit 873b79b867

View File

@ -156,7 +156,7 @@ void ThreadPlanStack::PushPlan(lldb::ThreadPlanSP new_plan_sp) {
lldb::ThreadPlanSP ThreadPlanStack::PopPlan() {
assert(m_plans.size() > 1 && "Can't pop the base thread plan");
lldb::ThreadPlanSP &plan_sp = m_plans.back();
lldb::ThreadPlanSP plan_sp = std::move(m_plans.back());
m_completed_plans.push_back(plan_sp);
plan_sp->WillPop();
m_plans.pop_back();
@ -166,7 +166,7 @@ lldb::ThreadPlanSP ThreadPlanStack::PopPlan() {
lldb::ThreadPlanSP ThreadPlanStack::DiscardPlan() {
assert(m_plans.size() > 1 && "Can't discard the base thread plan");
lldb::ThreadPlanSP &plan_sp = m_plans.back();
lldb::ThreadPlanSP plan_sp = std::move(m_plans.back());
m_discarded_plans.push_back(plan_sp);
plan_sp->WillPop();
m_plans.pop_back();