]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix BadValue crash when looking up empty color names on some X servers
authorPo Lu <luangruo@yahoo.com>
Fri, 21 Jan 2022 03:37:19 +0000 (11:37 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 21 Jan 2022 03:40:43 +0000 (11:40 +0800)
* src/xterm.c (x_parse_color): Avoid parsing empty color names.

src/xterm.c

index 5adbf210be30aa4580cd142a3680fc237f17046c..a53f2982c6b96c66e0f753c058be103e28a144c9 100644 (file)
@@ -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;