diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2003-06-24 19:56:12 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2003-06-24 19:56:12 (GMT) |
commit | b20771db513c20f371c108101f155a4524fd3e32 (patch) | |
tree | cd0d79fe92f149690056ea39961bbf825d10c7f6 | |
parent | e7ccc4eafaf9f3a162755aa1d6afccd3fd1eda13 (diff) | |
download | tcl-b20771db513c20f371c108101f155a4524fd3e32.zip tcl-b20771db513c20f371c108101f155a4524fd3e32.tar.gz tcl-b20771db513c20f371c108101f155a4524fd3e32.tar.bz2 |
No more div-by-zero errors. [Bug 759749]
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclHash.c | 6 |
2 files changed, 9 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2003-06-24 Donal K. Fellows <fellowsd@cs.man.ac.uk> + + * generic/tclHash.c (Tcl_HashStats): Prevented occurrence of + division-by-zero problems. [Bug 759749] + 2003-06-24 Mo DeJong <mdejong@users.sourceforge.net> * unix/tclUnixPort.h: #undef inet_ntoa before diff --git a/generic/tclHash.c b/generic/tclHash.c index 45726d9..9d63ffc 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclHash.c,v 1.12 2002/11/12 02:23:18 hobbs Exp $ + * RCS: @(#) $Id: tclHash.c,v 1.13 2003/06/24 19:56:12 dkf Exp $ */ #include "tclInt.h" @@ -766,7 +766,9 @@ Tcl_HashStats(tablePtr) overflow++; } tmp = j; - average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0; + if (tablePtr->numEntries != 0) { + average += (tmp+1.0)*(tmp/tablePtr->numEntries)/2.0; + } } /* |