]> granicus.if.org Git - icinga2/commitdiff
Fix: Dict initializer incorrectly re-initialized field that is set to an empty string
authorGunnar Beutner <gunnar@beutner.name>
Wed, 5 Aug 2015 05:45:10 +0000 (07:45 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 24 Aug 2015 11:31:16 +0000 (13:31 +0200)
fixes #9835

lib/config/expression.cpp

index 7350a97ae9a27210e4caeb9b7b7c18ade44a0aff..3b758dc4936ea7de6968c9d8d5416105cf31199f 100644 (file)
@@ -604,8 +604,12 @@ bool IndexerExpression::GetReference(ScriptFrame& frame, bool init_dict, Value *
                psdhint = *dhint;
 
        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;