emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r115538: Fix bug #16152 with crashes in process-send


From: Eli Zaretskii
Subject: [Emacs-diffs] trunk r115538: Fix bug #16152 with crashes in process-send-eof on MS-Windows.
Date: Sun, 15 Dec 2013 18:38:23 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115538
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/16152
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sun 2013-12-15 20:37:48 +0200
message:
  Fix bug #16152 with crashes in process-send-eof on MS-Windows.
  
   src/process.c (Fprocess_send_eof): Don't crash if someone tries to
   open a pty on MS-Windows.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/process.c                  process.c-20091113204419-o5vbwnq5f7feedwu-462
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-12-15 17:52:14 +0000
+++ b/src/ChangeLog     2013-12-15 18:37:48 +0000
@@ -1,5 +1,8 @@
 2013-12-15  Eli Zaretskii  <address@hidden>
 
+       * process.c (Fprocess_send_eof): Don't crash if someone tries to
+       open a pty on MS-Windows.  (Bug#16152)
+
        * emacs.c (decode_env_path): Fix bogus comparison against
        emacs_dir.  Reported by Juanma Barranquero <address@hidden>.
 

=== modified file 'src/process.c'
--- a/src/process.c     2013-11-23 02:58:28 +0000
+++ b/src/process.c     2013-12-15 18:37:48 +0000
@@ -6032,13 +6032,16 @@
   (Lisp_Object process)
 {
   Lisp_Object proc;
-  struct coding_system *coding;
+  struct coding_system *coding = NULL;
+  int outfd;
 
   if (DATAGRAM_CONN_P (process))
     return process;
 
   proc = get_process (process);
-  coding = proc_encode_coding_system[XPROCESS (proc)->outfd];
+  outfd = XPROCESS (proc)->outfd;
+  if (outfd >= 0)
+    coding = proc_encode_coding_system[outfd];
 
   /* Make sure the process is really alive.  */
   if (XPROCESS (proc)->raw_status_new)
@@ -6046,7 +6049,7 @@
   if (! EQ (XPROCESS (proc)->status, Qrun))
     error ("Process %s not running", SDATA (XPROCESS (proc)->name));
 
-  if (CODING_REQUIRE_FLUSHING (coding))
+  if (coding && CODING_REQUIRE_FLUSHING (coding))
     {
       coding->mode |= CODING_MODE_LAST_BLOCK;
       send_process (proc, "", 0, Qnil);
@@ -6064,7 +6067,8 @@
     }
   else
     {
-      int old_outfd = XPROCESS (proc)->outfd;
+      struct Lisp_Process *p = XPROCESS (proc);
+      int old_outfd = p->outfd;
       int new_outfd;
 
 #ifdef HAVE_SHUTDOWN
@@ -6072,24 +6076,30 @@
         for communication with the subprocess, call shutdown to cause EOF.
         (In some old system, shutdown to socketpair doesn't work.
         Then we just can't win.)  */
-      if (EQ (XPROCESS (proc)->type, Qnetwork)
-         || XPROCESS (proc)->infd == old_outfd)
+      if (EQ (p->type, Qnetwork)
+         || p->infd == old_outfd)
        shutdown (old_outfd, 1);
 #endif
-      close_process_fd (&XPROCESS (proc)->open_fd[WRITE_TO_SUBPROCESS]);
+      close_process_fd (&p->open_fd[WRITE_TO_SUBPROCESS]);
       new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0);
       if (new_outfd < 0)
        report_file_error ("Opening null device", Qnil);
-      XPROCESS (proc)->open_fd[WRITE_TO_SUBPROCESS] = new_outfd;
-      XPROCESS (proc)->outfd = new_outfd;
+      p->open_fd[WRITE_TO_SUBPROCESS] = new_outfd;
+      p->outfd = new_outfd;
 
       if (!proc_encode_coding_system[new_outfd])
        proc_encode_coding_system[new_outfd]
          = xmalloc (sizeof (struct coding_system));
-      *proc_encode_coding_system[new_outfd]
-       = *proc_encode_coding_system[old_outfd];
-      memset (proc_encode_coding_system[old_outfd], 0,
-             sizeof (struct coding_system));
+      if (old_outfd >= 0)
+       {
+         *proc_encode_coding_system[new_outfd]
+           = *proc_encode_coding_system[old_outfd];
+         memset (proc_encode_coding_system[old_outfd], 0,
+                 sizeof (struct coding_system));
+       }
+      else
+       setup_coding_system (p->encode_coding_system,
+                            proc_encode_coding_system[new_outfd]);
     }
   return process;
 }


reply via email to

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