[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8215: possibly uninitialized variable lower_xoff in produce_glyphles
bug#8215: possibly uninitialized variable lower_xoff in produce_glyphless_glyph
Wed, 09 Mar 2011 14:00:12 -0800
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:126.96.36.199) 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/xdisp.c's
produce_glyphless_glyph function might be using an uninitialized
if (base_width >= width)
/* Align the upper to the left, the lower to the right. */
it->pixel_width = base_width;
lower_xoff = base_width - 2 - metrics_lower.width;
/* Center the shorter one. */
it->pixel_width = width;
if (metrics_upper.width >= metrics_lower.width)
lower_xoff = (width - metrics_lower.width) / 2;
upper_xoff = (width - metrics_upper.width) / 2;
append_glyphless_glyph (it, face_id, for_no_font, len,
The last call uses lower_xoff, but the last "else" does not initialize
lower_xoff. The bug cannot occur if it->glyph_row is NULL, but I
don't see why that would necessarily be. So 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 initializing
lower_xoff to 0, with a FIXME explaining the situation: this shouldn't
introduce a bug, because at worst it will replace undefined behavior
with defined behavior.
I'm CC'ing this to Kenichi Handa, who committed the code in question.
|[Prev in Thread]
||[Next in Thread]|
- bug#8215: possibly uninitialized variable lower_xoff in produce_glyphless_glyph,
Paul Eggert <=