]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix usage of string data pointers in xfaces.c
authorEli Zaretskii <eliz@gnu.org>
Sat, 22 Mar 2025 16:45:38 +0000 (18:45 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 23 Mar 2025 19:25:36 +0000 (20:25 +0100)
* src/xfaces.c (tty_defined_color): Don't use SSDATA pointers
across calls to Lisp.  (Bug#77046)

(cherry picked from commit 9816c61c4876ac2acdc6d9efb73c4270846b5555)

src/xfaces.c

index fbbaffb8889c7a7b12de3f5dc224c9050c72a577..7a4571c00c4f7719c853cdc55c84fb73867563fe 100644 (file)
@@ -1150,14 +1150,18 @@ tty_defined_color (struct frame *f, const char *color_name,
   color_def->green = 0;
 
   if (*color_name)
-    status = tty_lookup_color (f, build_string (color_name), color_def, NULL);
-
-  if (color_def->pixel == FACE_TTY_DEFAULT_COLOR && *color_name)
     {
-      if (strcmp (color_name, "unspecified-fg") == 0)
-       color_def->pixel = FACE_TTY_DEFAULT_FG_COLOR;
-      else if (strcmp (color_name, "unspecified-bg") == 0)
-       color_def->pixel = FACE_TTY_DEFAULT_BG_COLOR;
+      Lisp_Object lcolor = build_string (color_name);
+      status = tty_lookup_color (f, lcolor, color_def, NULL);
+
+      if (color_def->pixel == FACE_TTY_DEFAULT_COLOR)
+       {
+         color_name = SSDATA (lcolor);
+         if (strcmp (color_name, "unspecified-fg") == 0)
+           color_def->pixel = FACE_TTY_DEFAULT_FG_COLOR;
+         else if (strcmp (color_name, "unspecified-bg") == 0)
+           color_def->pixel = FACE_TTY_DEFAULT_BG_COLOR;
+       }
     }
 
   if (color_def->pixel != FACE_TTY_DEFAULT_COLOR)