From 8af384fe4a8ef40ed8cf73e00b9f7a392c46909e Mon Sep 17 00:00:00 2001 From: dg Date: Fri, 5 May 1995 06:15:11 +0000 Subject: Check for 0 before dividing by it. Patch from Paul Traina, modified slightly by me. --- sys/dev/speaker/spkr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c index f9c72d6..170abb8 100644 --- a/sys/dev/speaker/spkr.c +++ b/sys/dev/speaker/spkr.c @@ -4,7 +4,7 @@ * v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993 * modified for FreeBSD by Andrew A. Chernov * - * $Id: spkr.c,v 1.11 1995/02/03 10:19:38 ache Exp $ + * $Id: spkr.c,v 1.12 1995/03/16 18:12:05 bde Exp $ */ #include "speaker.h" @@ -66,9 +66,14 @@ static void tone(thz, ticks) /* emit tone of frequency thz for given number of ticks */ unsigned int thz, ticks; { - unsigned int divisor = TIMER_CLK / thz; + unsigned int divisor; int sps; + if (thz <= 0) + return; + + divisor = TIMER_CLK / thz; + #ifdef DEBUG (void) printf("tone: thz=%d ticks=%d\n", thz, ticks); #endif /* DEBUG */ @@ -201,6 +206,9 @@ int pitch, value, sustain; sdenom *= DENOM_MULT; } + if (value == 0 || sdenom == 0) + return; + if (pitch == -1) rest(whole * snum / (value * sdenom)); else -- cgit v1.1