* commit 'a7501119e341626536ce12c3539c2f9a986a2945': Make Bitmap_createFromParcel check the color count. DO NOT MERGE
This commit is contained in:
@@ -505,24 +505,33 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkBitmap* bitmap = new SkBitmap;
|
SkAutoTDelete<SkBitmap> bitmap(new SkBitmap);
|
||||||
|
|
||||||
bitmap->setConfig(config, width, height, rowBytes);
|
if (!bitmap->setConfig(config, width, height, rowBytes)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
SkColorTable* ctable = NULL;
|
SkColorTable* ctable = NULL;
|
||||||
if (config == SkBitmap::kIndex8_Config) {
|
if (config == SkBitmap::kIndex8_Config) {
|
||||||
int count = p->readInt32();
|
int count = p->readInt32();
|
||||||
|
if (count < 0 || count > 256) {
|
||||||
|
// The data is corrupt, since SkColorTable enforces a value between 0 and 256,
|
||||||
|
// inclusive.
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
size_t size = count * sizeof(SkPMColor);
|
size_t size = count * sizeof(SkPMColor);
|
||||||
const SkPMColor* src = (const SkPMColor*)p->readInplace(size);
|
const SkPMColor* src = (const SkPMColor*)p->readInplace(size);
|
||||||
|
if (src == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
ctable = new SkColorTable(src, count);
|
ctable = new SkColorTable(src, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jbyteArray buffer = GraphicsJNI::allocateJavaPixelRef(env, bitmap, ctable);
|
jbyteArray buffer = GraphicsJNI::allocateJavaPixelRef(env, bitmap.get(), ctable);
|
||||||
if (NULL == buffer) {
|
if (NULL == buffer) {
|
||||||
SkSafeUnref(ctable);
|
SkSafeUnref(ctable);
|
||||||
delete bitmap;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,7 +543,6 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
|
|||||||
android::status_t status = p->readBlob(size, &blob);
|
android::status_t status = p->readBlob(size, &blob);
|
||||||
if (status) {
|
if (status) {
|
||||||
doThrowRE(env, "Could not read bitmap from parcel blob.");
|
doThrowRE(env, "Could not read bitmap from parcel blob.");
|
||||||
delete bitmap;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,8 +552,8 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
|
|||||||
|
|
||||||
blob.release();
|
blob.release();
|
||||||
|
|
||||||
return GraphicsJNI::createBitmap(env, bitmap, buffer, getPremulBitmapCreateFlags(isMutable),
|
return GraphicsJNI::createBitmap(env, bitmap.detach(), buffer,
|
||||||
NULL, NULL, density);
|
getPremulBitmapCreateFlags(isMutable), NULL, NULL, density);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
|
static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
|
||||||
|
|||||||
Reference in New Issue
Block a user