diff options
author | dg <dg@FreeBSD.org> | 1995-05-05 06:15:11 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1995-05-05 06:15:11 +0000 |
commit | 8af384fe4a8ef40ed8cf73e00b9f7a392c46909e (patch) | |
tree | 60b1846f5b134ca7bdd718b5181396306e8a4805 /sys/i386/isa/spkr.c | |
parent | dc68656289c37489839f2e2437e8bfa3b37415d8 (diff) | |
download | FreeBSD-src-8af384fe4a8ef40ed8cf73e00b9f7a392c46909e.zip FreeBSD-src-8af384fe4a8ef40ed8cf73e00b9f7a392c46909e.tar.gz |
Check for 0 before dividing by it. Patch from Paul Traina, modified
slightly by me.
Diffstat (limited to 'sys/i386/isa/spkr.c')
-rw-r--r-- | sys/i386/isa/spkr.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/i386/isa/spkr.c b/sys/i386/isa/spkr.c index f9c72d6..170abb8 100644 --- a/sys/i386/isa/spkr.c +++ b/sys/i386/isa/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 <ache@astral.msk.su> * - * $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 |