Fix a write out of bounds in splitvertical gradients (Bug 3612)
authorDana Jansens <danakj@orodu.net>
Sun, 11 Aug 2013 20:04:50 +0000 (16:04 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 11 Aug 2013 20:15:12 +0000 (16:15 -0400)
If the gradient has height 1, then y1sz is 0. We don't want to use the
first color and move the data pointer, since this will move it past the
end of the array.

obrender/gradient.c

index 60a0a55..7f2f1f8 100644 (file)
@@ -527,13 +527,15 @@ static void gradient_splitvertical(RrAppearance *a, gint w, gint h)
     /* find the color for the first pixel of each row first */
     data = sf->pixel_data;
 
-    for (y1 = y1sz-1; y1 > 0; --y1) {
+    if (y1sz) {
+        for (y1 = y1sz-1; y1 > 0; --y1) {
+            *data = COLOR(y1);
+            data += w;
+            NEXT(y1);
+        }
         *data = COLOR(y1);
         data += w;
-        NEXT(y1);
     }
-    *data = COLOR(y1);
-    data += w;
     if (y2sz) {
         for (y2 = y2sz-1; y2 > 0; --y2) {
             *data = COLOR(y2);