summaryrefslogtreecommitdiffstats
path: root/chrome/common/common_param_traits.cc
diff options
context:
space:
mode:
authorcevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-30 05:27:59 +0000
committercevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-30 05:27:59 +0000
commitd3d98bc21e6fe0ea6aa0186194347a1f5e4d7be8 (patch)
treefe9a0b5d158f3c76fad261b1e5d4f346f15c664e /chrome/common/common_param_traits.cc
parentb7855e597e91a340f203c1622ebc48070560d30f (diff)
downloadchromium_src-d3d98bc21e6fe0ea6aa0186194347a1f5e4d7be8.zip
chromium_src-d3d98bc21e6fe0ea6aa0186194347a1f5e4d7be8.tar.gz
chromium_src-d3d98bc21e6fe0ea6aa0186194347a1f5e4d7be8.tar.bz2
Fix up rowbytes vs. width desynchronization, and fix failure to initialize entire bitmap memory. To fix up the rowbytes value properly, we simply don't send it via IPC any more, and recalulate it from width and depth in the trusted code. It's a cheap calculation.
Also one bonus fix: don't use an unintialized IconInfo if deserialization fails. BUG=31307 TEST=Manual; ran with breakpoints on the failure paths. Review URL: http://codereview.chromium.org/517023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35371 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/common_param_traits.cc')
-rw-r--r--chrome/common/common_param_traits.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc
index 38682ba..684337d 100644
--- a/chrome/common/common_param_traits.cc
+++ b/chrome/common/common_param_traits.cc
@@ -27,24 +27,20 @@ struct SkBitmap_Data {
// The height of the bitmap in pixels.
uint32 fHeight;
- // The number of bytes between subsequent rows of the bitmap.
- uint32 fRowBytes;
-
void InitSkBitmapDataForTransfer(const SkBitmap& bitmap) {
fConfig = bitmap.config();
fWidth = bitmap.width();
fHeight = bitmap.height();
- fRowBytes = bitmap.rowBytes();
}
// 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->setConfig(fConfig, fWidth, fHeight, 0);
if (!bitmap->allocPixels())
return false;
- if (total_pixels > bitmap->getSize())
+ if (total_pixels != bitmap->getSize())
return false;
memcpy(bitmap->getPixels(), pixels, total_pixels);
}
@@ -205,15 +201,17 @@ bool ParamTraits<webkit_glue::WebApplicationInfo>::Read(
ReadParam(m, iter, &icon_count);
if (!result)
return false;
- for (size_t i = 0; i < icon_count && result; ++i) {
+ for (size_t i = 0; i < icon_count; ++i) {
param_type::IconInfo icon_info;
result =
ReadParam(m, iter, &icon_info.url) &&
ReadParam(m, iter, &icon_info.width) &&
ReadParam(m, iter, &icon_info.height);
+ if (!result)
+ return false;
r->icons.push_back(icon_info);
}
- return result;
+ return true;
}
void ParamTraits<webkit_glue::WebApplicationInfo>::Log(