Subject: bug#8229: closed (Re: bug#8215: bug#8229: possibly uninitialized variable in load_charset)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 02 Jun 2021 12:52:02 +0000

Your bug report

#8229: possibly uninitialized variable in load_charset

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
8229: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8229
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#8215: bug#8229: possibly uninitialized variable in load_charset
From: Eli Zaretskii <[email-masked]>
To: Lars Ingebrigtsen <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Wed, 02 Jun 2021 15:50:50 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Lars Ingebrigtsen <[email-masked]>
> Date: Wed, 02 Jun 2021 10:03:14 +0200
> Cc: [email-masked], [email-masked], [email-masked]
> 
> Paul Eggert <[email-masked]> writes:
> 
> > I committed my abovementioned workaround into the
> > Emacs trunk on 2011-03-11 (bzr 103589).  I don't
> > consider this a fix, though, so I'm leaving this
> > bug report open.
> 
> This was ten years ago:
> 
> commit 0ac2c2991c1cba4e3c6e5f7b62c7d61b01d69994
> Author:     Paul Eggert <[email-masked]>
> AuthorDate: Mon Mar 7 16:46:23 2011 -0800
> Commit:     Paul Eggert <[email-masked]>
> CommitDate: Mon Mar 7 16:46:23 2011 -0800
> 
>     * charset.c (load_charset): Abort instead of using uninitialized var.
> 
> The code is still pretty much identical, as far as I can tell.  Should
> this report be closed now?

I'm closing it.  I think non-unified charsets are rarely if ever used
in Emacs these days, but in any case, we have emacs_abort there, so if
the problem ever rears its ugly head, we will catch it.

Subject: possibly uninitialized variable in load_charset
From: Paul Eggert <[email-masked]>
To: [email-masked]
Cc: Kenichi Handa <[email-masked]>
Date: Thu, 10 Mar 2011 16:24:13 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

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.