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

Unified Diff: runtime/vm/object.h

Issue 2503423003: Don't crash attempting to JSON print an uninitialized Map. (Closed)
Patch Set: Created 4 years, 1 month 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 | « runtime/observatory/tests/service/service.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 0765fcc28fc31f9c6a14df52823b0377d89249e8..4e3919df9ae6b8878231ac8a183e1594b55fc1a0 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -8200,6 +8200,10 @@ class LinkedHashMap : public Instance {
}
intptr_t Length() const {
+ // The map may be uninitialized.
+ if (raw_ptr()->used_data_ == Object::null()) return 0;
+ if (raw_ptr()->deleted_keys_ == Object::null()) return 0;
+
intptr_t used = Smi::Value(raw_ptr()->used_data_);
intptr_t deleted = Smi::Value(raw_ptr()->deleted_keys_);
return (used >> 1) - deleted;
« no previous file with comments | « runtime/observatory/tests/service/service.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698