From: Andreas Schwab Date: Sun, 7 Sep 2008 20:35:14 +0000 (+0000) Subject: (Fcall_process): Don't hold references to string data X-Git-Tag: emacs-pretest-23.0.90~2959 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1aa83b226a79e35a9e5c63585f62a081bcc7f55e;p=emacs.git (Fcall_process): Don't hold references to string data across garbage collection. Move initialisation of new_argv down to avoid compiler bug. --- diff --git a/src/ChangeLog b/src/ChangeLog index 67cd1c3bb06..17796a27326 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-09-07 Andreas Schwab + + * callproc.c (Fcall_process): Don't hold references to string data + across garbage collection. Move initialisation of new_argv down + to avoid compiler bug. + 2008-09-07 Roland Winkler * process.c (Fsystem_process_attributes): Doc fix. diff --git a/src/callproc.c b/src/callproc.c index fdfa4c78083..5d94b05b608 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -226,8 +226,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) int bufsize = CALLPROC_BUFFER_SIZE_MIN; int count = SPECPDL_INDEX (); - register const unsigned char **new_argv - = (const unsigned char **) alloca ((max (2, nargs - 2)) * sizeof (char *)); + register const unsigned char **new_argv; struct buffer *old = current_buffer; /* File to use for stderr in the child. t means use same as standard output. */ @@ -414,7 +413,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) && SREF (path, 1) == ':') path = Fsubstring (path, make_number (2), Qnil); - new_argv[0] = SDATA (path); + new_argv = (const unsigned char **) + alloca (max (2, nargs - 2) * sizeof (char *)); if (nargs > 4) { register int i; @@ -428,13 +428,15 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) if (CODING_REQUIRE_ENCODING (&argument_coding)) /* We must encode this argument. */ args[i] = encode_coding_string (&argument_coding, args[i], 1); - new_argv[i - 3] = SDATA (args[i]); } UNGCPRO; - new_argv[nargs - 3] = 0; + for (i = 4; i < nargs; i++) + new_argv[i - 3] = SDATA (args[i]); + new_argv[i - 3] = 0; } else new_argv[1] = 0; + new_argv[0] = SDATA (path); #ifdef MSDOS /* MW, July 1993 */ if ((outf = egetenv ("TMPDIR")))