diff options
| author | Dana Jansens <danakj@orodu.net> | 2013-08-11 16:04:50 -0400 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2013-08-11 16:15:12 -0400 |
| commit | f3873cac4add6865cff6ca01abd65a31dc1b33ad (patch) | |
| tree | 1815413b9d8e401ecf45718d956fc9ce7cad48ec /obrender | |
| parent | cddd736de5933c909616f395cd774dac110ee9ae (diff) | |
Fix a write out of bounds in splitvertical gradients (Bug 3612)
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.
Diffstat (limited to 'obrender')
| -rw-r--r-- | obrender/gradient.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/obrender/gradient.c b/obrender/gradient.c index 60a0a555..7f2f1f8f 100644 --- a/obrender/gradient.c +++ b/obrender/gradient.c @@ -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); |
