[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8229: possibly uninitialized variable in load_charset
From: |
Paul Eggert |
Subject: |
bug#8229: possibly uninitialized variable in load_charset |
Date: |
Thu, 10 Mar 2011 16:24:13 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7 |
Severity: minor
I found this problem by compiling Emacs with GCC's -Wuninitialized flag.
The following code in the Emacs trunk src/charset.c's load_charset
function is suspicious, because as written it appears that it might be
using an uninitialized variable:
if (CHARSET_METHOD (charset) == CHARSET_METHOD_MAP)
map = CHARSET_MAP (charset);
else if (CHARSET_UNIFIED_P (charset))
map = CHARSET_UNIFY_MAP (charset);
if (STRINGP (map))
...
The last if-test uses "map", but it's not clear from the previous
tests that "map" must be initialized.
I'm filing a bug report so that someone who is more expert in this
code can take a look at it. In the meantime, I plan to work around
the problem by replacing:
else if (CHARSET_UNIFIED_P (charset))
map = CHARSET_UNIFY_MAP (charset);
with:
else
{
if (! CHARSET_UNIFIED_P (charset))
abort ();
map = CHARSET_UNIFY_MAP (charset);
}
I'm CC'ing this to Kenichi Handa, who committed the code in question.
- bug#8229: possibly uninitialized variable in load_charset,
Paul Eggert <=