diff --git a/ChangeLog b/ChangeLog index 08c9505c..5f2a8511 100644 --- a/ChangeLog +++ b/ChangeLog @@ -66,6 +66,8 @@ Changes since version 0.80.2: - Fixed bug in wmsetbg that caused scale and maxscale to both do maxscale (Alexey Voinov ) - Fixed bug with scrolling menus introduced by the xinerama patch. +- Fixed bug that could cause SIGSEGV by accessing beyond the end of text in + a WINGs textfield widget. Changes since version 0.80.1: diff --git a/WINGs/ChangeLog b/WINGs/ChangeLog index f2cdfce5..5073ef67 100644 --- a/WINGs/ChangeLog +++ b/WINGs/ChangeLog @@ -53,6 +53,8 @@ Changes since wmaker 0.80.1: - Added WMGetFontName() - Added fontpanel callback - Added WMSetTableViewHasHorizontalScroller() +- Fixed bug that could cause SIGSEGV by accessing beyond the end of text in + a WINGs textfield widget. Changes since wmaker 0.80.0: diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index 71a5b2cb..08fb61de 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -1335,12 +1335,13 @@ pointToCursorPosition(TextField *tPtr, int x) if (tPtr->flags.bordered) x -= 2; - a = tPtr->viewPosition; - b = tPtr->viewPosition + tPtr->textLen; if (WMWidthOfString(tPtr->font, &(tPtr->text[tPtr->viewPosition]), tPtr->textLen - tPtr->viewPosition) < x) return tPtr->textLen; + a = tPtr->viewPosition; + b = tPtr->textLen; + while (a < b && b-a>1) { mid = (a+b)/2; tw = WMWidthOfString(tPtr->font, &(tPtr->text[tPtr->viewPosition]), @@ -1352,6 +1353,7 @@ pointToCursorPosition(TextField *tPtr, int x) else return mid; } + return (a+b)/2; }