Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2424)

Unified Diff: pkg/serialization/lib/src/format.dart

Issue 12210151: Fix modification of map while iterating in SimpleJsonFormat (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes from review comments Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/pkg.status ('k') | pkg/serialization/test/serialization_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/serialization/lib/src/format.dart
diff --git a/pkg/serialization/lib/src/format.dart b/pkg/serialization/lib/src/format.dart
index ab602c92a2b80c29997324b736f7a592c07b1f08..a1726f0f5b979a82627cc96c356a793509399ba9 100644
--- a/pkg/serialization/lib/src/format.dart
+++ b/pkg/serialization/lib/src/format.dart
@@ -154,9 +154,15 @@ class SimpleJsonFormat extends Format {
* to turn References into a nested List/Map.
*/
jsonifyEntry(map, Writer w) {
+ // Note, if this is a Map, and the key might be a reference, we need to
+ // bend over backwards to avoid concurrent modifications. Non-string keys
+ // won't actually work if we try to write this to json, but might happen
+ // if e.g. sending between isolates.
+ var updates = new Map();
keysAndValues(map).forEach((key, value) {
- if (value is Reference) map[key] = w.stateForReference(value);
+ if (value is Reference) updates[key] = w.stateForReference(value);
});
+ updates.forEach((k, v) => map[k] = v);
}
/**
« no previous file with comments | « pkg/pkg.status ('k') | pkg/serialization/test/serialization_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698