| Index: chrome/common/ipc_message_utils.cc
|
| ===================================================================
|
| --- chrome/common/ipc_message_utils.cc (revision 14534)
|
| +++ chrome/common/ipc_message_utils.cc (working copy)
|
| @@ -33,13 +33,18 @@
|
| fRowBytes = bitmap.rowBytes();
|
| }
|
|
|
| - void InitSkBitmapFromData(SkBitmap* bitmap, const char* pixels,
|
| + // Returns whether |bitmap| successfully initialized.
|
| + bool InitSkBitmapFromData(SkBitmap* bitmap, const char* pixels,
|
| size_t total_pixels) const {
|
| if (total_pixels) {
|
| bitmap->setConfig(fConfig, fWidth, fHeight, fRowBytes);
|
| - bitmap->allocPixels();
|
| + if (!bitmap->allocPixels())
|
| + return false;
|
| + if (total_pixels > bitmap->getSize())
|
| + return false;
|
| memcpy(bitmap->getPixels(), pixels, total_pixels);
|
| }
|
| + return true;
|
| }
|
| };
|
|
|
| @@ -78,8 +83,7 @@
|
| }
|
| const SkBitmap_Data* bmp_data =
|
| reinterpret_cast<const SkBitmap_Data*>(fixed_data);
|
| - bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size);
|
| - return true;
|
| + return bmp_data->InitSkBitmapFromData(r, variable_data, variable_data_size);
|
| }
|
|
|
| void ParamTraits<SkBitmap>::Log(const SkBitmap& p, std::wstring* l) {
|
|
|