summaryrefslogtreecommitdiffstats
path: root/chrome/common/ipc_message_utils.cc
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 02:32:55 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-24 02:32:55 +0000
commit40ecd8a10372b6be9a2cb830dd1fe004b51ca2ec (patch)
tree0e0a766ee0a61f89dc23489e54f96fbf172ddc6b /chrome/common/ipc_message_utils.cc
parentd191f78bb4a4f91fec1d75f0905fe14e592914e7 (diff)
downloadchromium_src-40ecd8a10372b6be9a2cb830dd1fe004b51ca2ec.zip
chromium_src-40ecd8a10372b6be9a2cb830dd1fe004b51ca2ec.tar.gz
chromium_src-40ecd8a10372b6be9a2cb830dd1fe004b51ca2ec.tar.bz2
Try 14398 again, with Mac fix.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_message_utils.cc')
-rw-r--r--chrome/common/ipc_message_utils.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/chrome/common/ipc_message_utils.cc b/chrome/common/ipc_message_utils.cc
index 36e8052..8ce3f4f 100644
--- a/chrome/common/ipc_message_utils.cc
+++ b/chrome/common/ipc_message_utils.cc
@@ -33,13 +33,18 @@ struct SkBitmap_Data {
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 @@ bool ParamTraits<SkBitmap>::Read(const Message* m, void** iter, SkBitmap* r) {
}
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) {