emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 c2727e3: Fix crashes when run with --no-build-det


From: Paul Eggert
Subject: [Emacs-diffs] emacs-26 c2727e3: Fix crashes when run with --no-build-details
Date: Thu, 8 Feb 2018 12:32:52 -0500 (EST)

branch: emacs-26
commit c2727e3c40bcafdc7c32b3f02b78e6cbe87e1647
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 src/xrdb.c  | 19 +++++++++++--------
 src/xterm.c | 16 +++++++++++-----
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/src/xrdb.c b/src/xrdb.c
index b55c0f9..836c147 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -376,15 +376,18 @@ get_environ_db (void)
 
   if (!p)
     {
-      /* Use ~/.Xdefaults-HOSTNAME.  */
-      char *home = gethomedir ();
-      ptrdiff_t homelen = strlen (home);
       Lisp_Object system_name = Fsystem_name ();
-      ptrdiff_t filenamesize = (homelen + sizeof xdefaults
-                               + 1 + SBYTES (system_name));
-      p = filename = xrealloc (home, filenamesize);
-      lispstpcpy (stpcpy (stpcpy (filename + homelen, xdefaults), "-"),
-                 system_name);
+      if (STRINGP (system_name))
+       {
+         /* Use ~/.Xdefaults-HOSTNAME.  */
+         char *home = gethomedir ();
+         ptrdiff_t homelen = strlen (home);
+         ptrdiff_t filenamesize = (homelen + sizeof xdefaults
+                                   + 1 + SBYTES (system_name));
+         p = filename = xrealloc (home, filenamesize);
+         lispstpcpy (stpcpy (stpcpy (filename + homelen, xdefaults), "-"),
+                     system_name);
+       }
     }
 
   db = XrmGetFileDatabase (p);
diff --git a/src/xterm.c b/src/xterm.c
index 364a8a8..b10664d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12150,6 +12150,8 @@ same_x_server (const char *name1, const char *name2)
 {
   bool seen_colon = false;
   Lisp_Object sysname = Fsystem_name ();
+  if (! STRINGP (sysname))
+    sysname = empty_unibyte_string;
   const char *system_name = SSDATA (sysname);
   ptrdiff_t system_name_length = SBYTES (sysname);
   ptrdiff_t length_until_period = 0;
@@ -12572,15 +12574,19 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
 #endif
 
   Lisp_Object system_name = Fsystem_name ();
-  ptrdiff_t nbytes;
-  if (INT_ADD_WRAPV (SBYTES (Vinvocation_name), SBYTES (system_name) + 2,
-                    &nbytes))
+
+  ptrdiff_t nbytes = SBYTES (Vinvocation_name) + 1;
+  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);
   char *nametail = lispstpcpy (dpyinfo->x_id_name, Vinvocation_name);
-  *nametail++ = '@';
-  lispstpcpy (nametail, system_name);
+  if (STRINGP (system_name))
+    {
+      *nametail++ = '@';
+      lispstpcpy (nametail, system_name);
+    }
 
   /* Figure out which modifier bits mean what.  */
   x_find_modifier_meanings (dpyinfo);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]