summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2015-06-18 13:03:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-18 13:03:34 +0000
commit8c6750ff0eb2d07039336bf25dc87f10464c42db (patch)
tree1b199d6d4fd412569d9ecb13c02f8bd414593c80 /core
parent6bc12244480fcdeca84080d5382d63eb2b992883 (diff)
parent2a6d6e504712dcddd030a6007d9dfbb089258619 (diff)
downloadframeworks_base-8c6750ff0eb2d07039336bf25dc87f10464c42db.zip
frameworks_base-8c6750ff0eb2d07039336bf25dc87f10464c42db.tar.gz
frameworks_base-8c6750ff0eb2d07039336bf25dc87f10464c42db.tar.bz2
Merge "Fixes for Region_writeToParcel." into mnc-dev
Diffstat (limited to 'core')
-rw-r--r--core/jni/android/graphics/Region.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/jni/android/graphics/Region.cpp b/core/jni/android/graphics/Region.cpp
index 3bab2df..e99bdfc 100644
--- a/core/jni/android/graphics/Region.cpp
+++ b/core/jni/android/graphics/Region.cpp
@@ -231,15 +231,24 @@ static jlong Region_createFromParcel(JNIEnv* env, jobject clazz, jobject parcel)
static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, jlong regionHandle, jobject parcel)
{
const SkRegion* region = reinterpret_cast<SkRegion*>(regionHandle);
- if (parcel == NULL) {
+ if (parcel == nullptr) {
return JNI_FALSE;
}
android::Parcel* p = android::parcelForJavaObject(env, parcel);
- size_t size = region->writeToMemory(NULL);
+ const size_t size = region->writeToMemory(nullptr);
p->writeInt32(size);
- region->writeToMemory(p->writeInplace(size));
+ void* dst = p->writeInplace(size);
+ if (dst == nullptr) {
+ ALOGE("Region.writeToParcel could not write %zi bytes", size);
+ return JNI_FALSE;
+ }
+ const size_t sizeWritten = region->writeToMemory(dst);
+ if (sizeWritten != size) {
+ ALOGE("SkRegion::writeToMemory should have written %zi bytes but wrote %zi",
+ size, sizeWritten);
+ }
return JNI_TRUE;
}