From 2adc0bd0429b51b19cab4a6c01c94b62ffb2111b Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 20 Jun 2022 14:54:08 +0200 Subject: [PATCH] ConfigItem: Fix infinite recursion caused by `ignore_on_error` when committing an item When committing an item with `ignore_on_error` flag set fails, the `Commit()` method only returns `nullptr` and the current item is not being dropped from `m_Items`. `CommittNewItems()` also doesn't check the return value of `Commit()` but just continues and tries to commit all items from `m_Items` in recursive call. Since this corrupt item is never removed from `m_Items`, it ends up in an endless recursion till it finally crashes. --- lib/config/configitem.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 3dd31df9c..6d93570ee 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -470,7 +470,14 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue if (item->m_Type != type) return; - ip.first->Commit(ip.second); + if (!item->Commit(ip.second)) { + if (item->IsIgnoreOnError()) { + item->Unregister(); + } + + return; + } + committed_items++; });