diff --git a/src/xterm.c b/src/xterm.c index 0d2452de92..05353a2ec2 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -12927,24 +12927,19 @@ #define NUM_ARGV 10 XSetAfterFunction (x_current_display, x_trace_wire); #endif - Lisp_Object system_name = Fsystem_name (); static char const title[] = "GNU Emacs"; + static char const at[] = " at "; + Lisp_Object system_name = Fsystem_name (); + ptrdiff_t nbytes = sizeof (title) + sizeof (at); + if (STRINGP (system_name) + && INT_ADD_WRAPV (nbytes, SBYTES (system_name) + 1, &nbytes)) + memory_full (SIZE_MAX); + dpyinfo->x_id = ++x_display_id; + dpyinfo->x_id_name = xmalloc (nbytes); if (STRINGP (system_name)) - { - static char const at[] = " at "; - ptrdiff_t nbytes = sizeof (title) + sizeof (at); - if (INT_ADD_WRAPV (nbytes, SBYTES (system_name), &nbytes)) - memory_full (SIZE_MAX); - dpyinfo->x_id_name = xmalloc (nbytes); sprintf (dpyinfo->x_id_name, "%s%s%s", title, at, SDATA (system_name)); - } else - { - dpyinfo->x_id_name = xmalloc (sizeof (title)); strcpy (dpyinfo->x_id_name, title); - } - - dpyinfo->x_id = ++x_display_id; /* Figure out which modifier bits mean what. */ x_find_modifier_meanings (dpyinfo);