emacs-devel
[Top][All Lists]
Advanced

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

Re: Problem report #60


From: David Kastrup
Subject: Re: Problem report #60
Date: Tue, 11 Apr 2006 20:02:55 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

"Stuart D. Herring" <address@hidden> writes:

>> 8608           volatile Lisp_Object original_uppercase;
>> 8609           volatile int original_uppercase_position = -1;
>> [...]
>
> original_uppercase_position remains -1 if original_uppercase is
> uninitialized.
>
>> At conditional (20): "dont_downcase_last != 0" taking true path
>> At conditional (21): "(t - 1) == original_uppercase_position" taking true
>> path
>>
>> 9481           if ((dont_downcase_last || first_binding >= nmaps)
>> 9482               && t - 1 == original_uppercase_position)
>
> Assuming that t!=0, t-1==original_uppercase_position implies that the o_u
> variables were set.
>
>> Event uninit_use: Using uninitialized value "original_uppercase"
>> Also see events: [var_decl]
>>
>> 9483             keybuf[t - 1] = original_uppercase;
>> 9484
>
> So this is fine.  It'd be a big bug if t were 0, though, indexing at -1
> like that.  Looking back up, it seems that if the while loop iterates even
> once, t is > 0, but what if the while test fails the first time?  It looks
> like t would be 0, and original_uppercase_position would still be -1, and
> uninitialized data would be stored outside of an array.  Nasty, if it can
> happen.  Otherwise, no bug.

Then this should not be written as

while (condition)
{ body
}

but rather

assert(condition);
do { body
} while (condition);

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

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