aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-02-06 15:25:45 -0800
committerPaul Eggert2018-02-08 09:31:20 -0800
commitc2727e3c40bcafdc7c32b3f02b78e6cbe87e1647 (patch)
treebb0b585b6862cc8f2f154806a3391c536150b2af /src
parentdc08490ac7547403e306b1ba2c00a158933854ff (diff)
downloademacs-c2727e3c40bcafdc7c32b3f02b78e6cbe87e1647.tar.gz
emacs-c2727e3c40bcafdc7c32b3f02b78e6cbe87e1647.zip
Fix crashes when run with --no-build-details
* src/xrdb.c (get_environ_db): * src/xterm.c (same_x_server, x_term_init): Don’t assume Fsystem_name returns a string.
Diffstat (limited to 'src')
-rw-r--r--src/xrdb.c19
-rw-r--r--src/xterm.c16
2 files changed, 22 insertions, 13 deletions
diff --git a/src/xrdb.c b/src/xrdb.c
index b55c0f9011e..836c147947a 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -376,15 +376,18 @@ get_environ_db (void)
376 376
377 if (!p) 377 if (!p)
378 { 378 {
379 /* Use ~/.Xdefaults-HOSTNAME. */
380 char *home = gethomedir ();
381 ptrdiff_t homelen = strlen (home);
382 Lisp_Object system_name = Fsystem_name (); 379 Lisp_Object system_name = Fsystem_name ();
383 ptrdiff_t filenamesize = (homelen + sizeof xdefaults 380 if (STRINGP (system_name))
384 + 1 + SBYTES (system_name)); 381 {
385 p = filename = xrealloc (home, filenamesize); 382 /* Use ~/.Xdefaults-HOSTNAME. */
386 lispstpcpy (stpcpy (stpcpy (filename + homelen, xdefaults), "-"), 383 char *home = gethomedir ();
387 system_name); 384 ptrdiff_t homelen = strlen (home);
385 ptrdiff_t filenamesize = (homelen + sizeof xdefaults
386 + 1 + SBYTES (system_name));
387 p = filename = xrealloc (home, filenamesize);
388 lispstpcpy (stpcpy (stpcpy (filename + homelen, xdefaults), "-"),
389 system_name);
390 }
388 } 391 }
389 392
390 db = XrmGetFileDatabase (p); 393 db = XrmGetFileDatabase (p);
diff --git a/src/xterm.c b/src/xterm.c
index 364a8a8db02..b10664dda97 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12150,6 +12150,8 @@ same_x_server (const char *name1, const char *name2)
12150{ 12150{
12151 bool seen_colon = false; 12151 bool seen_colon = false;
12152 Lisp_Object sysname = Fsystem_name (); 12152 Lisp_Object sysname = Fsystem_name ();
12153 if (! STRINGP (sysname))
12154 sysname = empty_unibyte_string;
12153 const char *system_name = SSDATA (sysname); 12155 const char *system_name = SSDATA (sysname);
12154 ptrdiff_t system_name_length = SBYTES (sysname); 12156 ptrdiff_t system_name_length = SBYTES (sysname);
12155 ptrdiff_t length_until_period = 0; 12157 ptrdiff_t length_until_period = 0;
@@ -12572,15 +12574,19 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
12572#endif 12574#endif
12573 12575
12574 Lisp_Object system_name = Fsystem_name (); 12576 Lisp_Object system_name = Fsystem_name ();
12575 ptrdiff_t nbytes; 12577
12576 if (INT_ADD_WRAPV (SBYTES (Vinvocation_name), SBYTES (system_name) + 2, 12578 ptrdiff_t nbytes = SBYTES (Vinvocation_name) + 1;
12577 &nbytes)) 12579 if (STRINGP (system_name)
12580 && INT_ADD_WRAPV (nbytes, SBYTES (system_name) + 1, &nbytes))
12578 memory_full (SIZE_MAX); 12581 memory_full (SIZE_MAX);
12579 dpyinfo->x_id = ++x_display_id; 12582 dpyinfo->x_id = ++x_display_id;
12580 dpyinfo->x_id_name = xmalloc (nbytes); 12583 dpyinfo->x_id_name = xmalloc (nbytes);
12581 char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name); 12584 char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name);
12582 *nametail++ = '@'; 12585 if (STRINGP (system_name))
12583 lispstpcpy (nametail, system_name); 12586 {
12587 *nametail++ = '@';
12588 lispstpcpy (nametail, system_name);
12589 }
12584 12590
12585 /* Figure out which modifier bits mean what. */ 12591 /* Figure out which modifier bits mean what. */
12586 x_find_modifier_meanings (dpyinfo); 12592 x_find_modifier_meanings (dpyinfo);