From 7a842ef77c057a64ccda5ed71765d50658442747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 5 Oct 2009 12:46:26 +0000 Subject: [PATCH] Check negative out-of-bounds index in BTextView::OffsetAt(). According to #4707, this is the BeOS behavior. I have not checked myself and the BeBook is very brief on this, but similar methods do trim indices to be in range. Another alternative would be returning an index indicating an error (-1). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33439 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/TextView.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 37c4a75077..1c44d67081 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -1913,6 +1913,8 @@ BTextView::OffsetAt(BPoint point) const int32 BTextView::OffsetAt(int32 line) const { + if (line < 0) + return 0; if (line > fLines->NumLines()) return fText->Length();