http://www.jwz.org/xscreensaver/xscreensaver-5.11.tar.gz
[xscreensaver] / hacks / substrate.c
index 6b0cb823bfe0c2ca9112fce1d34f04a1617991f7..82c2bacd483b58c68703919e4aa047624a7b138b 100644 (file)
@@ -198,6 +198,13 @@ static inline void start_crack(struct field *f, crack *cr)
         /* We timed out.  Use our default values */
         px = cr->x;
         py = cr->y;
+
+        /* Sanity check needed */
+        if (px < 0) px = 0;
+        if (px >= f->width) px = f->width - 1;
+        if (py < 0) py = 0;
+        if (py >= f->height) py = f->height - 1;
+
         ref_cgrid(f, px, py) = cr->t;
     }