[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
From: |
Andreas Schwab |
Subject: |
bug#8211: uninitialized variable in detect_coding_iso_2022's end-of-composition code |
Date: |
Wed, 09 Mar 2011 23:30:21 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2.94 (gnu/linux) |
Paul Eggert <eggert@cs.ucla.edu> writes:
> 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 */
> break;
> composition_count = -1;
> found |= CATEGORY_MASK_ISO;
> }
> else
> ...
>
> /* We found a valid designation sequence for CHARSET. */
> rejected |= CATEGORY_MASK_ISO_8BIT;
> if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7],
> id))
> 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 think it just lacks a break. ESC '1' is not a designation sequence.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."