diff options
| author | Eli Zaretskii | 2020-10-03 20:49:18 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2020-10-03 20:49:18 +0300 |
| commit | 0fe8ab79e7a2306b84e209cc4e90da1996da1cad (patch) | |
| tree | 1464d684c4d585e8cc465ffd61c68c5ccb8cf005 /src | |
| parent | f4305f3b53152126cce466b19f79d3348a5b2f2c (diff) | |
| download | emacs-0fe8ab79e7a2306b84e209cc4e90da1996da1cad.tar.gz emacs-0fe8ab79e7a2306b84e209cc4e90da1996da1cad.zip | |
Avoid segfaults in lookup_image when faces were freed
* src/image.c (lookup_image): Make sure the frame's face cache
exists and has at least the basic faces. If FACE_ID is not a
basic face, and is no longer cached, fall back on the 'default'
face. (Bug#43700)
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/image.c b/src/image.c index 6ecf6a70fe2..25d5af8a8d5 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -2329,8 +2329,14 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id) | |||
| 2329 | struct image *img; | 2329 | struct image *img; |
| 2330 | EMACS_UINT hash; | 2330 | EMACS_UINT hash; |
| 2331 | 2331 | ||
| 2332 | struct face *face = (face_id >= 0) ? FACE_FROM_ID (f, face_id) | 2332 | if (FRAME_FACE_CACHE (f) == NULL) |
| 2333 | : FACE_FROM_ID (f, DEFAULT_FACE_ID); | 2333 | init_frame_faces (f); |
| 2334 | if (FRAME_FACE_CACHE (f)->used == 0) | ||
| 2335 | recompute_basic_faces (f); | ||
| 2336 | if (face_id < 0 || face_id >= FRAME_FACE_CACHE (f)->used) | ||
| 2337 | face_id = DEFAULT_FACE_ID; | ||
| 2338 | |||
| 2339 | struct face *face = FACE_FROM_ID (f, face_id); | ||
| 2334 | unsigned long foreground = FACE_COLOR_TO_PIXEL (face->foreground, f); | 2340 | unsigned long foreground = FACE_COLOR_TO_PIXEL (face->foreground, f); |
| 2335 | unsigned long background = FACE_COLOR_TO_PIXEL (face->background, f); | 2341 | unsigned long background = FACE_COLOR_TO_PIXEL (face->background, f); |
| 2336 | 2342 | ||