OSDN Git Service

DO NOT MERGE: Ensure that unparcelling Region only reads the expected number of bytes
authorLeon Scroggins III <scroggo@google.com>
Fri, 29 May 2015 20:13:11 +0000 (16:13 -0400)
committerThe Android Automerger <android-build@google.com>
Fri, 14 Aug 2015 02:41:42 +0000 (19:41 -0700)
bug: 20883006
Change-Id: I4f109667fb210a80fbddddf5f1bfb7ef3a02b6ce

core/jni/android/graphics/Region.cpp

index 6b99de8..ec4d8bf 100644 (file)
@@ -218,7 +218,12 @@ static jlong Region_createFromParcel(JNIEnv* env, jobject clazz, jobject parcel)
         return NULL;
     }
     SkRegion* region = new SkRegion;
-    region->readFromMemory(regionData, size);
+    size_t actualSize = region->readFromMemory(regionData, size);
+
+    if (size != actualSize) {
+        delete region;
+        return NULL;
+    }
 
     return reinterpret_cast<jlong>(region);
 }