From 6892d8a2655f2976198a07b14dcd2c981e2d1de9 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Fri, 13 May 2011 07:58:26 +0000 Subject: [PATCH] STR 2630: added bounds check for very narrow text editing widgets, wishing that Valgrind was available for OS X git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8659 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Text_Display.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 17ca17f2a..d82261780 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -420,7 +420,8 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) { /* if empty lines become visible, there may be an opportunity to display more text by scrolling down */ } else { - while ( (mLineStarts[mNVisibleLines-2]==-1) + while ( mNVisibleLines>=2 + && (mLineStarts[mNVisibleLines-2]==-1) && scroll_(mTopLineNum-1, mHorizOffset)) { } } @@ -974,7 +975,7 @@ void Fl_Text_Display::display_insert() { if (insert_position() < mFirstChar) { topLine -= count_lines(insert_position(), mFirstChar, false); - } else if (mLineStarts[mNVisibleLines-2] != -1) { + } else if (mNVisibleLines>=2 && mLineStarts[mNVisibleLines-2] != -1) { int lastChar = line_end(mLineStarts[mNVisibleLines-2],true); if (insert_position() >= lastChar) topLine += count_lines(lastChar - (wrap_uses_character(mLastChar) ? 0 : 1),