[PATCH libXaw] fix potential infinte loop in XawBoxQueryGeometry() (bug 11569)

Matt Turner mattst88 at gmail.com
Fri Dec 3 14:24:56 PST 2010


From: Glenn Burkhardt <gbburkhardt at verizon.net>

Originally sent to xorg@ back in July 2007.
http://lists.x.org/archives/xorg/2007-July/025997.html

---
Please don't ignore it this time.

 src/Box.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/Box.c b/src/Box.c
index 7aa14a5..5336908 100644
--- a/src/Box.c
+++ b/src/Box.c
@@ -392,9 +392,10 @@ XawBoxQueryGeometry(Widget widget, XtWidgetGeometry *constraint,
 	if (preferred_width <= constraint->width) {
 	    width = preferred_width;
 	    do { /* find some width big enough to stay within this height */
-		width <<= 1;
-		if (width > constraint->width)
+		if (width > constraint->width >> 1) /* avoid short int overflow */
 		    width = constraint->width;
+		else
+		    width <<= 1;
 		DoLayout(w, width, 0, &preferred_width, &preferred_height, False);
 	    } while (preferred_height > constraint->height
 		     && width < constraint->width);
-- 
1.7.2.2



More information about the xorg-devel mailing list