From: Gunnar Beutner <gunnar@beutner.name> Date: Wed, 5 Aug 2015 05:45:10 +0000 (+0200) Subject: Fix: Dict initializer incorrectly re-initialized field that is set to an empty string X-Git-Tag: v2.4.0~443 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7bfc5ef165819457e238af142ad2f1efad19a3b;p=icinga2 Fix: Dict initializer incorrectly re-initialized field that is set to an empty string fixes #9835 --- diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 5b26aa2ba..f251910f9 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -632,8 +632,12 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value * init_dict = false; if (m_Operand1->GetReference(frame, init_dict, &vparent, &vindex, &psdhint)) { - if (init_dict && VMOps::GetField(vparent, vindex, m_Operand1->GetDebugInfo()).IsEmpty()) - VMOps::SetField(vparent, vindex, new Dictionary(), m_Operand1->GetDebugInfo()); + if (init_dict) { + Value old_value = VMOps::GetField(vparent, vindex, m_Operand1->GetDebugInfo()); + + if (old_value.IsEmpty() && !old_value.IsString()) + VMOps::SetField(vparent, vindex, new Dictionary(), m_Operand1->GetDebugInfo()); + } *parent = VMOps::GetField(vparent, vindex, m_DebugInfo); free_psd = true;