summaryrefslogtreecommitdiff
path: root/src/process.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@linux-m68k.org>2009-04-28 19:02:26 +0000
committerAndreas Schwab <schwab@linux-m68k.org>2009-04-28 19:02:26 +0000
commit77bf07e14ef041325679bc274f912b5e9977eb25 (patch)
treea33270f5c27f175d5e26c65070e81c823d1663b5 /src/process.c
parent0a56bf8c52c6f6448a0ee97cab75a0b6fafca5ca (diff)
* fns.c (Flocale_info): Protect vector from GC during decoding.
* process.c (Fstart_process): Protect argv strings from GC during encoding.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/src/process.c b/src/process.c
index 143c58030c1..3e06b4d5fdb 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1698,8 +1698,6 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
XPROCESS (proc)->encode_coding_system = val;
}
- new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
-
/* If program file name is not absolute, search our path for it.
Put the name we will really use in TEM. */
if (!IS_DIRECTORY_SEP (SREF (program, 0))
@@ -1729,26 +1727,42 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
&& SREF (tem, 1) == ':')
tem = Fsubstring (tem, make_number (2), Qnil);
- /* Encode the file name and put it in NEW_ARGV.
- That's where the child will use it to execute the program. */
- tem = ENCODE_FILE (tem);
- new_argv[0] = SDATA (tem);
+ {
+ struct gcpro gcpro1;
+ GCPRO1 (tem);
+
+ /* Encode the file name and put it in NEW_ARGV.
+ That's where the child will use it to execute the program. */
+ tem = Fcons (ENCODE_FILE (tem), Qnil);
+
+ /* Here we encode arguments by the coding system used for sending
+ data to the process. We don't support using different coding
+ systems for encoding arguments and for encoding data sent to the
+ process. */
+
+ for (i = 3; i < nargs; i++)
+ {
+ tem = Fcons (args[i], tem);
+ CHECK_STRING (XCAR (tem));
+ if (STRING_MULTIBYTE (XCAR (tem)))
+ XSETCAR (tem,
+ code_convert_string_norecord
+ (XCAR (tem), XPROCESS (proc)->encode_coding_system, 1));
+ }
- /* Here we encode arguments by the coding system used for sending
- data to the process. We don't support using different coding
- systems for encoding arguments and for encoding data sent to the
- process. */
+ UNGCPRO;
+ }
- for (i = 3; i < nargs; i++)
+ /* Now that everything is encoded we can collect the strings into
+ NEW_ARGV. */
+ new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
+ new_argv[nargs - 2] = 0;
+
+ for (i = nargs - 3; i >= 0; i--)
{
- tem = args[i];
- CHECK_STRING (tem);
- if (STRING_MULTIBYTE (tem))
- tem = (code_convert_string_norecord
- (tem, XPROCESS (proc)->encode_coding_system, 1));
- new_argv[i - 2] = SDATA (tem);
+ new_argv[i] = SDATA (XCAR (tem));
+ tem = XCDR (tem);
}
- new_argv[i - 2] = 0;
XPROCESS (proc)->decoding_buf = make_uninit_string (0);
XPROCESS (proc)->decoding_carryover = 0;