Module Name:    src
Committed By:   charlotte
Date:           Wed Feb 28 23:14:37 UTC 2024

Modified Files:
        src/games/rain: rain.c

Log Message:
rain(6): Avoid division by zero

If there were exactly 4 LINES or COLS then we'd attempt to draw a raindrop
at some value mod 0, which is invalid.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/games/rain/rain.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/rain/rain.c
diff -u src/games/rain/rain.c:1.22 src/games/rain/rain.c:1.23
--- src/games/rain/rain.c:1.22	Wed Oct 14 18:32:04 2020
+++ src/games/rain/rain.c	Wed Feb 28 23:14:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: rain.c,v 1.22 2020/10/14 18:32:04 nia Exp $	*/
+/*	$NetBSD: rain.c,v 1.23 2024/02/28 23:14:37 charlotte Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)rain.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: rain.c,v 1.22 2020/10/14 18:32:04 nia Exp $");
+__RCSID("$NetBSD: rain.c,v 1.23 2024/02/28 23:14:37 charlotte Exp $");
 #endif
 #endif /* not lint */
 
@@ -97,6 +97,8 @@ main(int argc, char **argv)
 		errx(0, "couldn't initialize screen");
 	cols = COLS - 4;
 	lines = LINES - 4;
+	if (cols == 0) cols++;
+	if (lines == 0) lines++;
 
 	(void)signal(SIGHUP, onsig);
 	(void)signal(SIGINT, onsig);

Reply via email to