discuss-gnustep
[Top][All Lists]
Advanced

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

Re: PC segmentation fault


From: Riccardo Mottola
Subject: Re: PC segmentation fault
Date: Sun, 22 Sep 2013 20:45:22 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0 SeaMonkey/2.21

Hi,

Wolfgang Lux wrote:
Okay, upon a second inspection the original termination condition i < _length + 
1 may be right, but in that case the assignment endType = codeType(_uchar+end) is 
wrong. In fact, you do not need this assignment and the local variable endType at 
all. Instead the condition in the if statement should be corrected. Change
   if ((startType != endType) || (end == _length))
into
   if (end == _length || startType != codeType(_uchar+end))
so that the array access is made only within the bounds of the buffer.
Interestingly, that fixed the error, but just delayed the crash. By stressing a bit the parser, it ended crashing again: if you notice, the "start" (start = i) will walk up... till past the end. Since I think it is useless to assign the start to the last character, since it will anyway check and exit, I guarded that last startType look up.
It seems to work! I'll commit right now.


I am also checking to change many variables to NSUIntger when length/count is involved or at least NSInteger where -1 is used (Although perhaps NSNotFound could be used perhaps). I hope I won't break it.

Riccardo



reply via email to

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