Ticket #9217: 0001-Handle-BTextView-Select-out-of-range-values-better.patch

File 0001-Handle-BTextView-Select-out-of-range-values-better.patch, 1.2 KB (added by AGMS, 11 years ago)

Patch to fix the range checking bug.

  • src/kits/interface/TextView.cpp

    From 206e1f28d8064459ebf3a40bbd52816e7571b0be Mon Sep 17 00:00:00 2001
    From: Alexander G. M. Smith <agmsmith@ncf.ca>
    Date: Sun, 25 Nov 2012 14:57:21 -0500
    Subject: [PATCH] Handle BTextView::Select() out of range values better.
    
    Selection ranges with start values out of the valid range aren't
    handled the same way BeOS does, which is to peg them to valid numbers.
    Currently only end values are clipped, start isn't fully pegged.
    
    * This affects software like TTAnywhere, which uses
      Select(1000000000, 1000000000) to position the selection point at
      the end before appending text to a log window.
    
    * It also may affect bug #9066, where Select is in the stack crawl.
    ---
     src/kits/interface/TextView.cpp |    2 ++
     1 files changed, 2 insertions(+), 0 deletions(-)
    
    diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp
    index cb08c8d..1d68631 100644
    a b BTextView::Select(int32 startOffset, int32 endOffset)  
    15511551    // pin offsets at reasonable values
    15521552    if (startOffset < 0)
    15531553        startOffset = 0;
     1554    else if (startOffset > fText->Length())
     1555        startOffset = fText->Length();
    15541556    if (endOffset < 0)
    15551557        endOffset = 0;
    15561558    else if (endOffset > fText->Length())