discuss-gnustep
[Top][All Lists]
Advanced

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

Re: ProjectCenter Editor parenthesis highlighting segfault


From: Wolfgang Lux
Subject: Re: ProjectCenter Editor parenthesis highlighting segfault
Date: Tue, 26 Aug 2014 14:06:29 +0200

Am 26.08.2014 um 13:24 schrieb Riccardo Mottola:

> Hi,
> 
> Wolfgang Lux wrote:
>> your fix looks obviously correct to me, so I've committed the change and 
>> also added a similar, though less important, bounds check to method 
>> -highlightCharacterAt:inEditor: as well.
> yes, the fix looks correct, I was just wondering why it doesn't fail for me. 
> I suppose that in my case "-1" is always found and the loop exists for that. 
> GCC always respected the order of boolean expressions, to my knowledge. 
> Perhaps something else is malfunctioning, but better a bound check and a 
> failed highlight than a segfault!

Honestly, I was wondering as well why the code could segfault. With the way the 
code works either highlited_chars[0] and highlited_chars[1] are both -1 or they 
are both different from -1. If both are different from -1, the old code was 
reading highlited_chars[2], which does not exist, before the loop condition 
failed on the i<2 test. But the loop body should not have been entered with the 
old code either. Also an access to highlited_chars[2] should not really fail 
(the value would be read from the next storage location, which likely belongs 
to the previousFGColor attribute). But then checking the index condition before 
reading from an array is good practice anyway, which is why I committed the 
change in the end.

Wolfgang




reply via email to

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