[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8211: uninitialized variable in detect_coding_iso_2022's end-of-comp
bug#8211: uninitialized variable in detect_coding_iso_2022's end-of-composition code
Wed, 09 Mar 2011 09:53:39 -0800
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:18.104.22.168) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7
I found this problem by compiling Emacs with GCC's -Wuninitialized flag.
The following code in the Emacs trunk src/coding.c's
detect_coding_iso_2022 function apparently uses an uninitialized variable:
else if (c == '1')
/* End of composition. */
if (composition_count < 0
|| composition_count > MAX_COMPOSITION_COMPONENTS)
/* Invalid */
composition_count = -1;
found |= CATEGORY_MASK_ISO;
/* We found a valid designation sequence for CHARSET. */
rejected |= CATEGORY_MASK_ISO_8BIT;
if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7],
found |= CATEGORY_MASK_ISO_7;
The problem is that the "else if (c == '1')" branch does not initialize
the local variable "id", but the second "if" test uses that variable.
I plan to work around the uninitialized-variable problem by initializing
"id" to zero. This will replace undefined behavior with defined behavior,
so it shouldn't introduce a new bug, but it probably doesn't fix the
bug in question, assuming there is one. Could an expert in this
area please review this and come up with a real fix?
I'm CC'ing this to Kenichi Handa, who committed the code in question.
- bug#8211: uninitialized variable in detect_coding_iso_2022's end-of-composition code,
Paul Eggert <=