discuss-gnustep
[Top][All Lists]
Advanced

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

Possible Bug in NSString.m


From: Roland Schwingel
Subject: Possible Bug in NSString.m
Date: Tue, 16 Jul 2002 17:27:56 +0200


Hi...

I assume a bug in NSString.m method:
- (void) getLineStart: (unsigned *)startIndex  end: (unsigned *)lineEndIndex  contentsEnd: (unsigned *)contentsEndIndex  forRange: (NSRange)aRange

When you read the code carefully you will find this (about line 1852 in gnustep-base-1.1.0):
...
 if (lineEndIndex)
{
  if (end < len
    && ((*caiImp)(self, caiSel, end) == (unichar)0x000D)
    && ((*caiImp)(self, caiSel, end+1) == (unichar)0x000A))
    {
      *lineEndIndex = end+1;
    }
  else
    {
      *lineEndIndex = end;
    }
}
...

When one will assume that end and len are just one number away
(eg end==101 and len==102 ) - what can happen when you read the whole method - the
((*caiImp)(self, caiSel, end+1) == (unichar)0x000A) in the second if() statement
will fail with a Rangeexception in GSStrings characterAtIndex_c() because you read
one letter out of range...

If this is true maybe this should be fixed...

Roland

PS: This is my first posting to this list I hope I am right here...

reply via email to

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