summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 01:07:53 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 01:07:53 +0000
commit2e087265468db6369a65f3da28f0c2777788bcb6 (patch)
treecf140ac8ad909672cf0bb7be680c86570145486f /chrome/browser/gtk
parent128ff759facb55e3c0c1326e97c00b325ac3f484 (diff)
downloadchromium_src-2e087265468db6369a65f3da28f0c2777788bcb6.zip
chromium_src-2e087265468db6369a65f3da28f0c2777788bcb6.tar.gz
chromium_src-2e087265468db6369a65f3da28f0c2777788bcb6.tar.bz2
Don't try to set transparency on pixbufs that don't have any transparency channel.
Also add DCHECK to make sure the assumption rowstride >= width * 4 is true. The reason this didn't cause any crashes or graphical corruption is because the non-transparent images don't have any white in them (luckily we are not making a browser for an ipod). BUG=16749 TEST=valgrind the browser, open find bar Review URL: http://codereview.chromium.org/155547 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/nine_box.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc
index af2de61..66e7793 100644
--- a/chrome/browser/gtk/nine_box.cc
+++ b/chrome/browser/gtk/nine_box.cc
@@ -138,11 +138,21 @@ void NineBox::ChangeWhiteToTransparent() {
if (!pixbuf)
continue;
+ if (!gdk_pixbuf_get_has_alpha(pixbuf))
+ continue;
+
guchar* pixels = gdk_pixbuf_get_pixels(pixbuf);
int rowstride = gdk_pixbuf_get_rowstride(pixbuf);
+ int width = gdk_pixbuf_get_width(pixbuf);
+ int height = gdk_pixbuf_get_height(pixbuf);
+
+ if (width * 4 > rowstride) {
+ NOTREACHED();
+ continue;
+ }
- for (int i = 0; i < gdk_pixbuf_get_height(pixbuf); ++i) {
- for (int j = 0; j < gdk_pixbuf_get_width(pixbuf); ++j) {
+ for (int i = 0; i < height; ++i) {
+ for (int j = 0; j < width; ++j) {
guchar* pixel = &pixels[i * rowstride + j * 4];
if (pixel[0] == 0xff && pixel[1] == 0xff && pixel[2] == 0xff) {
pixel[3] = 0;