From 36bc3348cc2394d14ffe52fe293828f22702e36f Mon Sep 17 00:00:00 2001 From: Scott Blomquist Date: Tue, 2 Sep 2014 17:28:13 -0700 Subject: [PATCH] Fix crash on attempting to frame with @embed filtering. --- src/JsonLD/Core/JsonLdApi.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/JsonLD/Core/JsonLdApi.cs b/src/JsonLD/Core/JsonLdApi.cs index 065e952..60d61b8 100644 --- a/src/JsonLD/Core/JsonLdApi.cs +++ b/src/JsonLD/Core/JsonLdApi.cs @@ -1663,9 +1663,14 @@ private static void RemoveDependents(IDictionary em , string id) { // get embed keys as a separate array to enable deleting keys in map - foreach (string id_dep in embeds.Keys) + List embedsKeys = new List(embeds.Keys); + foreach (string id_dep in embedsKeys) { - JsonLdApi.EmbedNode e = embeds[id_dep]; + JsonLdApi.EmbedNode e; + if (!embeds.TryGetValue(id_dep, out e)) + { + continue; + } JToken p = !e.parent.IsNull() ? e.parent : new JObject(); if (!(p is JObject)) {