summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/nine_box.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/gtk/nine_box.cc')
-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;