OSDN Git Service

am 11297581: am 18d79267: Check that the parcel contained the expected amount of...
authorLeon Scroggins III <scroggo@google.com>
Wed, 27 May 2015 14:53:00 +0000 (14:53 +0000)
committerAndroid Git Automerger <android-git-automerger@android.com>
Wed, 27 May 2015 14:53:00 +0000 (14:53 +0000)
* commit '11297581667128d2568a47ee03acab5c4f9f2784':
  Check that the parcel contained the expected amount of region data. DO NOT MERGE

1  2 
core/jni/android/graphics/Region.cpp

@@@ -212,18 -175,21 +212,22 @@@ static jlong Region_createFromParcel(JN
  
      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 region;
 +    return reinterpret_cast<jlong>(region);
  }
  
 -static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, const SkRegion* region, jobject parcel)
 +static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, jlong regionHandle, jobject parcel)
  {
 +    const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
      if (parcel == NULL) {
 -        return false;
 +        return JNI_FALSE;
      }
  
      android::Parcel* p = android::parcelForJavaObject(env, parcel);