am 2bbcc253: am b36ace74: Merge "Check that the parcel contained the expected amount of region data. DO NOT MERGE" into lmp-dev
* commit '2bbcc253254a497b8f9bb86712fb6f0f2548e9f2':
Check that the parcel contained the expected amount of region data. DO NOT MERGE
diff --git a/core/jni/android/graphics/Region.cpp b/core/jni/android/graphics/Region.cpp
index 912968a..6b99de8 100644
--- a/core/jni/android/graphics/Region.cpp
+++ b/core/jni/android/graphics/Region.cpp
@@ -212,9 +212,13 @@
android::Parcel* p = android::parcelForJavaObject(env, parcel);
+ const size_t size = p->readInt32();
+ const void* regionData = p->readInplace(size);
+ if (regionData == NULL) {
+ return NULL;
+ }
SkRegion* region = new SkRegion;
- size_t size = p->readInt32();
- region->readFromMemory(p->readInplace(size), size);
+ region->readFromMemory(regionData, size);
return reinterpret_cast<jlong>(region);
}