From: Paul Eggert Date: Mon, 27 Jan 2025 06:15:49 +0000 (-0800) Subject: Avoid undefined behavior with botched pgtk menu X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fb8e5412c10c1fe1845f566d4229953d0db9d907;p=emacs.git Avoid undefined behavior with botched pgtk menu * src/pgtkmenu.c (pgtk_menu_show): Do not dereference save_wv if null. Problem found by gcc 20250110 (Red Hat 14.2.1-7) -Wanalyzer-null-dereference. (cherry picked from commit c0d83876f18cb21abae299d3b4a2a2bd7f117252) --- diff --git a/src/pgtkmenu.c b/src/pgtkmenu.c index 54e1c3739cf..e7a862b0c18 100644 --- a/src/pgtkmenu.c +++ b/src/pgtkmenu.c @@ -725,7 +725,7 @@ pgtk_menu_show (struct frame *f, int x, int y, int menuflags, STRINGP (help) ? help : Qnil); if (prev_wv) prev_wv->next = wv; - else + else if (save_wv) save_wv->contents = wv; if (!NILP (descrip)) wv->key = SSDATA (descrip);