]> code.delx.au - gnu-emacs/blobdiff - src/xsmfns.c
Fix last change
[gnu-emacs] / src / xsmfns.c
index 48aaa9bef8a1870c968df49e7b18f76bea3d9f91..8c4a6d3462c2832f4a050ff62f38aeff73ce8e3b 100644 (file)
@@ -28,11 +28,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <unistd.h>
 #include <sys/param.h>
+#include <errno.h>
 #include <stdio.h>
 
 #include "lisp.h"
-#include "systime.h"
-#include "sysselect.h"
 #include "frame.h"
 #include "termhooks.h"
 #include "xterm.h"
@@ -224,9 +223,8 @@ smc_save_yourself_CB (SmcConn smcConn,
   props[props_idx]->name = xstrdup (SmRestartCommand);
   props[props_idx]->type = xstrdup (SmLISTofARRAY8);
   /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir ... */
-  if (INT_MAX - 3 < initial_argc)
+  if (INT_ADD_WRAPV (initial_argc, 3, &i))
     memory_full (SIZE_MAX);
-  i = 3 + initial_argc;
   props[props_idx]->num_vals = i;
   vp = xnmalloc (i, sizeof *vp);
   props[props_idx]->vals = vp;
@@ -402,6 +400,14 @@ x_session_initialize (struct x_display_info *dpyinfo)
   SmcCallbacks callbacks;
   ptrdiff_t name_len = 0;
 
+  /* libSM seems to crash if pwd is missing - see bug#18851.  */
+  if (! get_current_dir_name ())
+    {
+      fprintf (stderr, "Disabling session management due to pwd error: %s\n",
+               emacs_strerror (errno));
+      return;
+    }
+
   ice_fd = -1;
   doing_interact = false;