diff options
author | Markus Steinborn <gnugv_maintainer@yahoo.de> | 2012-03-01 18:08:22 +0100 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2012-03-24 21:22:56 -0700 |
commit | 5d367cd9d0cd8fa5a85ed442e30dab4222824a36 (patch) | |
tree | 3c914370287f3f1dd26c355fc99f998633fd9be5 /src | |
parent | 39e9a67b05d4558c065aedd2ebbe6eb11d0b88de (diff) |
Avoid integer overflow
Found at http://gitorious.org/xaw3d/xaw3d/commit/3ba3e52454bb684a73601ec91e2c274e776f711a
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Box.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -351,8 +351,12 @@ PreferredSize(Widget widget, XtWidgetGeometry *constraint, XtWidgetGeometry *pre else { width = preferred_width; do { /* find some width big enough to stay within this height */ - width *= 2; - if (width > constraint->width) width = constraint->width; + if (width > constraint->width/2) { /* avoid short int overflow */ + width = constraint->width; + } + else { + width *= 2; + } DoLayout(w, width, 0, &preferred_width, &preferred_height, FALSE); } while (preferred_height > constraint->height && width < constraint->width); |