[automerger] Verify number of Map entries written to Parcel am: 057a01d1f3 am: d6947f1cbf am: 628cbe5c53
Change-Id: Id32bd5aa02d5689873bb311eebc87f367af9a9d9
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index f6e6ad6..0591fa8 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -692,11 +692,19 @@
return;
}
Set<Map.Entry<String,Object>> entries = val.entrySet();
- writeInt(entries.size());
+ int size = entries.size();
+ writeInt(size);
+
for (Map.Entry<String,Object> e : entries) {
writeValue(e.getKey());
writeValue(e.getValue());
+ size--;
}
+
+ if (size != 0) {
+ throw new BadParcelableException("Map size does not match number of entries!");
+ }
+
}
/**