bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix, NSLayoutManager


From: Fred Kiefer
Subject: Re: Fix, NSLayoutManager
Date: Fri, 12 Mar 2004 19:59:43 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030821

Georg Fleischmann wrote:
Hi,

here is a little patch for the NSLayoutManager fixing a problem with layout_char. layout_char is unsigned but may become "negative", thus flipping over to huge positive. The huge positive value then is not sattisfying the '<' comparison.

Georg


2004-03-10  Georg Fleischmann
        * gui/Source/NSLayoutManager.m [NSLayoutManager textStorage:...]:
          keep (unsigned) layout_char in legal range, in case it becomes < 0



*** gui/Source/NSLayoutManager.m.old    2004-02-15 19:23:13.000000000 +0100
--- gui/Source/NSLayoutManager.m        2004-03-10 19:30:38.000000000 +0100
***************
*** 1800,1806 ****
    if (layout_char > r.location)
      {
        layout_char += lengthChange;
!       if (layout_char < r.location)
          layout_char = r.location;
      }

--- 1800,1806 ----
    if (layout_char > r.location)
      {
        layout_char += lengthChange;
!       if (layout_char < r.location || layout_char > r.location + r.length)
          layout_char = r.location;
      }

I think you did spot a real problem here, but your solution just doesn't look right. An unsigned number never should be allowed to wrap around. What about a check like this:

    if (layout_char > r.location)
      {
        if (layout_char + lengthChange < r.location)
          {
            layout_char = r.location;
          }
        else
          {
            layout_char += lengthChange;
          }
      }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]