summaryrefslogtreecommitdiffstats
path: root/generic/tkPack.c
diff options
context:
space:
mode:
authordas <das>2008-12-07 16:35:44 (GMT)
committerdas <das>2008-12-07 16:35:44 (GMT)
commit4de20b70dcc086c8ecb0418a9f5b362a87f311cc (patch)
treed70ef3fedc61e5d0011b44dc99d0f0edc43121e1 /generic/tkPack.c
parent3751f59aa906bc929c67d1f6099a118668cb8bfb (diff)
downloadtk-4de20b70dcc086c8ecb0418a9f5b362a87f311cc.zip
tk-4de20b70dcc086c8ecb0418a9f5b362a87f311cc.tar.gz
tk-4de20b70dcc086c8ecb0418a9f5b362a87f311cc.tar.bz2
Fix potential divide by zero flagged by clang static analyzer
Diffstat (limited to 'generic/tkPack.c')
-rw-r--r--generic/tkPack.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/generic/tkPack.c b/generic/tkPack.c
index 2233a9f..b1dcd6a 100644
--- a/generic/tkPack.c
+++ b/generic/tkPack.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: tkPack.c,v 1.31 2008/11/08 22:52:29 dkf Exp $
+ * RCS: @(#) $Id: tkPack.c,v 1.32 2008/12/07 16:35:44 das Exp $
*/
#include "tkInt.h"
@@ -893,9 +893,11 @@ XExpansion(
childWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
+ slavePtr->padX + slavePtr->iPadX;
if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) {
- curExpand = (cavityWidth - childWidth)/numExpand;
- if (curExpand < minExpand) {
- minExpand = curExpand;
+ if (numExpand) {
+ curExpand = (cavityWidth - childWidth)/numExpand;
+ if (curExpand < minExpand) {
+ minExpand = curExpand;
+ }
}
} else {
cavityWidth -= childWidth;
@@ -904,9 +906,11 @@ XExpansion(
}
}
}
- curExpand = cavityWidth/numExpand;
- if (curExpand < minExpand) {
- minExpand = curExpand;
+ if (numExpand) {
+ curExpand = cavityWidth/numExpand;
+ if (curExpand < minExpand) {
+ minExpand = curExpand;
+ }
}
return (minExpand < 0) ? 0 : minExpand;
}
@@ -948,9 +952,11 @@ YExpansion(
childHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
+ slavePtr->padY + slavePtr->iPadY;
if ((slavePtr->side == LEFT) || (slavePtr->side == RIGHT)) {
- curExpand = (cavityHeight - childHeight)/numExpand;
- if (curExpand < minExpand) {
- minExpand = curExpand;
+ if (numExpand) {
+ curExpand = (cavityHeight - childHeight)/numExpand;
+ if (curExpand < minExpand) {
+ minExpand = curExpand;
+ }
}
} else {
cavityHeight -= childHeight;
@@ -959,9 +965,11 @@ YExpansion(
}
}
}
- curExpand = cavityHeight/numExpand;
- if (curExpand < minExpand) {
- minExpand = curExpand;
+ if (numExpand) {
+ curExpand = cavityHeight/numExpand;
+ if (curExpand < minExpand) {
+ minExpand = curExpand;
+ }
}
return (minExpand < 0) ? 0 : minExpand;
}