diff options
| author | Andreas Schwab | 2009-04-28 19:02:26 +0000 |
|---|---|---|
| committer | Andreas Schwab | 2009-04-28 19:02:26 +0000 |
| commit | 77bf07e14ef041325679bc274f912b5e9977eb25 (patch) | |
| tree | a33270f5c27f175d5e26c65070e81c823d1663b5 /src/process.c | |
| parent | 0a56bf8c52c6f6448a0ee97cab75a0b6fafca5ca (diff) | |
| download | emacs-77bf07e14ef041325679bc274f912b5e9977eb25.tar.gz emacs-77bf07e14ef041325679bc274f912b5e9977eb25.zip | |
* 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.c | 50 |
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) */) | |||
| 1698 | XPROCESS (proc)->encode_coding_system = val; | 1698 | XPROCESS (proc)->encode_coding_system = val; |
| 1699 | } | 1699 | } |
| 1700 | 1700 | ||
| 1701 | new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); | ||
| 1702 | |||
| 1703 | /* If program file name is not absolute, search our path for it. | 1701 | /* If program file name is not absolute, search our path for it. |
| 1704 | Put the name we will really use in TEM. */ | 1702 | Put the name we will really use in TEM. */ |
| 1705 | if (!IS_DIRECTORY_SEP (SREF (program, 0)) | 1703 | if (!IS_DIRECTORY_SEP (SREF (program, 0)) |
| @@ -1729,26 +1727,42 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1729 | && SREF (tem, 1) == ':') | 1727 | && SREF (tem, 1) == ':') |
| 1730 | tem = Fsubstring (tem, make_number (2), Qnil); | 1728 | tem = Fsubstring (tem, make_number (2), Qnil); |
| 1731 | 1729 | ||
| 1732 | /* Encode the file name and put it in NEW_ARGV. | 1730 | { |
| 1733 | That's where the child will use it to execute the program. */ | 1731 | struct gcpro gcpro1; |
| 1734 | tem = ENCODE_FILE (tem); | 1732 | GCPRO1 (tem); |
| 1735 | new_argv[0] = SDATA (tem); | 1733 | |
| 1734 | /* Encode the file name and put it in NEW_ARGV. | ||
| 1735 | That's where the child will use it to execute the program. */ | ||
| 1736 | tem = Fcons (ENCODE_FILE (tem), Qnil); | ||
| 1737 | |||
| 1738 | /* Here we encode arguments by the coding system used for sending | ||
| 1739 | data to the process. We don't support using different coding | ||
| 1740 | systems for encoding arguments and for encoding data sent to the | ||
| 1741 | process. */ | ||
| 1742 | |||
| 1743 | for (i = 3; i < nargs; i++) | ||
| 1744 | { | ||
| 1745 | tem = Fcons (args[i], tem); | ||
| 1746 | CHECK_STRING (XCAR (tem)); | ||
| 1747 | if (STRING_MULTIBYTE (XCAR (tem))) | ||
| 1748 | XSETCAR (tem, | ||
| 1749 | code_convert_string_norecord | ||
| 1750 | (XCAR (tem), XPROCESS (proc)->encode_coding_system, 1)); | ||
| 1751 | } | ||
| 1736 | 1752 | ||
| 1737 | /* Here we encode arguments by the coding system used for sending | 1753 | UNGCPRO; |
| 1738 | data to the process. We don't support using different coding | 1754 | } |
| 1739 | systems for encoding arguments and for encoding data sent to the | ||
| 1740 | process. */ | ||
| 1741 | 1755 | ||
| 1742 | for (i = 3; i < nargs; i++) | 1756 | /* Now that everything is encoded we can collect the strings into |
| 1757 | NEW_ARGV. */ | ||
| 1758 | new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); | ||
| 1759 | new_argv[nargs - 2] = 0; | ||
| 1760 | |||
| 1761 | for (i = nargs - 3; i >= 0; i--) | ||
| 1743 | { | 1762 | { |
| 1744 | tem = args[i]; | 1763 | new_argv[i] = SDATA (XCAR (tem)); |
| 1745 | CHECK_STRING (tem); | 1764 | tem = XCDR (tem); |
| 1746 | if (STRING_MULTIBYTE (tem)) | ||
| 1747 | tem = (code_convert_string_norecord | ||
| 1748 | (tem, XPROCESS (proc)->encode_coding_system, 1)); | ||
| 1749 | new_argv[i - 2] = SDATA (tem); | ||
| 1750 | } | 1765 | } |
| 1751 | new_argv[i - 2] = 0; | ||
| 1752 | 1766 | ||
| 1753 | XPROCESS (proc)->decoding_buf = make_uninit_string (0); | 1767 | XPROCESS (proc)->decoding_buf = make_uninit_string (0); |
| 1754 | XPROCESS (proc)->decoding_carryover = 0; | 1768 | XPROCESS (proc)->decoding_carryover = 0; |