diff options
| author | Po Lu | 2022-01-21 11:37:19 +0800 |
|---|---|---|
| committer | Po Lu | 2022-01-21 11:40:43 +0800 |
| commit | e9e5d0ba7342f709080090857d9d37ea07a49c81 (patch) | |
| tree | 61fd18a197aef8da5dd2f75a128b44396e631f2a /src | |
| parent | 9a0842dffe0013f4cca4853278ac3eaf94c4d3fc (diff) | |
| download | emacs-e9e5d0ba7342f709080090857d9d37ea07a49c81.tar.gz emacs-e9e5d0ba7342f709080090857d9d37ea07a49c81.zip | |
Fix BadValue crash when looking up empty color names on some X servers
* src/xterm.c (x_parse_color): Avoid parsing empty color names.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 9 |
1 files changed, 7 insertions, 2 deletions
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) | |||
| 2789 | and names we've actually looked up; list-colors-display is probably | 2789 | and names we've actually looked up; list-colors-display is probably |
| 2790 | the most color-intensive case we're likely to hit. */ | 2790 | the most color-intensive case we're likely to hit. */ |
| 2791 | 2791 | ||
| 2792 | Status x_parse_color (struct frame *f, const char *color_name, | 2792 | Status |
| 2793 | XColor *color) | 2793 | x_parse_color (struct frame *f, const char *color_name, |
| 2794 | XColor *color) | ||
| 2794 | { | 2795 | { |
| 2795 | /* Don't pass #RGB strings directly to XParseColor, because that | 2796 | /* Don't pass #RGB strings directly to XParseColor, because that |
| 2796 | follows the X convention of zero-extending each channel | 2797 | follows the X convention of zero-extending each channel |
| @@ -2819,6 +2820,10 @@ Status x_parse_color (struct frame *f, const char *color_name, | |||
| 2819 | } | 2820 | } |
| 2820 | } | 2821 | } |
| 2821 | 2822 | ||
| 2823 | /* Some X servers send BadValue on empty color names. */ | ||
| 2824 | if (!strlen (color_name)) | ||
| 2825 | return 0; | ||
| 2826 | |||
| 2822 | if (XParseColor (dpy, cmap, color_name, color) == 0) | 2827 | if (XParseColor (dpy, cmap, color_name, color) == 0) |
| 2823 | /* No caching of negative results, currently. */ | 2828 | /* No caching of negative results, currently. */ |
| 2824 | return 0; | 2829 | return 0; |