From: Po Lu Date: Fri, 21 Jan 2022 03:37:19 +0000 (+0800) Subject: Fix BadValue crash when looking up empty color names on some X servers X-Git-Tag: emacs-29.0.90~2884 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e9e5d0ba7342f709080090857d9d37ea07a49c81;p=emacs.git Fix BadValue crash when looking up empty color names on some X servers * src/xterm.c (x_parse_color): Avoid parsing empty color names. --- diff --git a/src/xterm.c b/src/xterm.c index 5adbf210be3..a53f2982c6b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -2789,8 +2789,9 @@ x_query_frame_background_color (struct frame *f, XColor *bgcolor) and names we've actually looked up; list-colors-display is probably the most color-intensive case we're likely to hit. */ -Status x_parse_color (struct frame *f, const char *color_name, - XColor *color) +Status +x_parse_color (struct frame *f, const char *color_name, + XColor *color) { /* Don't pass #RGB strings directly to XParseColor, because that follows the X convention of zero-extending each channel @@ -2819,6 +2820,10 @@ Status x_parse_color (struct frame *f, const char *color_name, } } + /* Some X servers send BadValue on empty color names. */ + if (!strlen (color_name)) + return 0; + if (XParseColor (dpy, cmap, color_name, color) == 0) /* No caching of negative results, currently. */ return 0;