summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@comhem.se>2006-09-07 11:40:01 +0000
committerMikael Magnusson <mikachu@comhem.se>2006-09-07 11:40:01 +0000
commit6930bdb289213f61ee11ef0f7efd173a34249110 (patch)
tree9be39fc9462c68020071d7ca8632efa1e03bbdaf /render
parent1fbc70da580b94dfcfe1a8549ed512eb02c5b73a (diff)
fix a crash when using mirrorhorizontal and resizing a window to width 1
Diffstat (limited to 'render')
-rw-r--r--render/gradient.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/render/gradient.c b/render/gradient.c
index d2cb6814..91fe4e27 100644
--- a/render/gradient.c
+++ b/render/gradient.c
@@ -458,28 +458,30 @@ static void gradient_mirrorhorizontal(RrSurface *sf, gint w, gint h)
VARS(x);
SETUP(x, sf->primary, sf->secondary, w/2);
- for (x = w - 1; x > w/2-1; --x) { /* 0 -> w-1 */
- current = COLOR(x);
- datav = data;
- for (y = h - 1; y >= 0; --y) { /* 0 -> h */
- *datav = current;
- datav += w;
- }
- ++data;
+ if (w > 1) {
+ for (x = w - 1; x > w/2-1; --x) { /* 0 -> w-1 */
+ current = COLOR(x);
+ datav = data;
+ for (y = h - 1; y >= 0; --y) { /* 0 -> h */
+ *datav = current;
+ datav += w;
+ }
+ ++data;
- NEXT(x);
- }
- SETUP(x, sf->secondary, sf->primary, w/2);
- for (x = w/2 - 1; x > 0; --x) { /* 0 -> w-1 */
- current = COLOR(x);
- datav = data;
- for (y = h - 1; y >= 0; --y) { /* 0 -> h */
- *datav = current;
- datav += w;
+ NEXT(x);
}
- ++data;
+ SETUP(x, sf->secondary, sf->primary, w/2);
+ for (x = w/2 - 1; x > 0; --x) { /* 0 -> w-1 */
+ current = COLOR(x);
+ datav = data;
+ for (y = h - 1; y >= 0; --y) { /* 0 -> h */
+ *datav = current;
+ datav += w;
+ }
+ ++data;
- NEXT(x);
+ NEXT(x);
+ }
}
current = COLOR(x);
for (y = h - 1; y >= 0; --y) /* 0 -> h */