diff --git a/src/xfns.c b/src/xfns.c index 7427144b103..7ec6025ab66 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1398,10 +1398,9 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) if (x_had_errors_p (dpy)) { const char *bad_cursor_name = NULL; - /* Bounded by X_ERROR_MESSAGE_SIZE in xterm.c. */ - size_t message_length = strlen (cursor_data.error_string); - char *xmessage = alloca (1 + message_length); - memcpy (xmessage, cursor_data.error_string, message_length); + char xmessage[X_ERROR_MESSAGE_SIZE]; + eassert (strlen (cursor_data.error_string) < sizeof xmessage); + strcpy (xmessage, cursor_data.error_string); x_uncatch_errors_after_check (); diff --git a/src/xterm.c b/src/xterm.c index 1401693541c..b2a0d2cadcc 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -26321,8 +26321,6 @@ x_unwind_errors_to (int depth) x_uncatch_errors (); } -#define X_ERROR_MESSAGE_SIZE 200 - /* An X error handler which stores the error message in the first applicable handler in the x_error_message stack. This is called from *x_error_handler if an x_catch_errors for DISPLAY is in diff --git a/src/xterm.h b/src/xterm.h index 962c856e772..28b720c9222 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -129,6 +129,8 @@ typedef GtkWidget *xt_or_gtk_widget; #include "dispextern.h" #include "termhooks.h" +enum { X_ERROR_MESSAGE_SIZE = 200 }; + INLINE_HEADER_BEGIN /* Black and white pixel values for the screen which frame F is on. */