comparison src/process.c @ 103095:65cc22e2c624

* fns.c (Flocale_info): Protect vector from GC during decoding. * process.c (Fstart_process): Protect argv strings from GC during encoding.
author Andreas Schwab <schwab@linux-m68k.org>
date Tue, 28 Apr 2009 19:02:26 +0000
parents 0f4ba7f17aa0
children e61fae00d13e
comparison
equal deleted inserted replaced
103094:64ac89a8b9a8 103095:65cc22e2c624
1696 val = XCDR (Vdefault_process_coding_system); 1696 val = XCDR (Vdefault_process_coding_system);
1697 } 1697 }
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))
1706 && !(SCHARS (program) > 1 1704 && !(SCHARS (program) > 1
1707 && IS_DEVICE_SEP (SREF (program, 1)))) 1705 && IS_DEVICE_SEP (SREF (program, 1))))
1727 discard that. */ 1725 discard that. */
1728 if (SBYTES (tem) > 2 && SREF (tem, 0) == '/' 1726 if (SBYTES (tem) > 2 && SREF (tem, 0) == '/'
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
1736 1734 /* Encode the file name and put it in NEW_ARGV.
1737 /* Here we encode arguments by the coding system used for sending 1735 That's where the child will use it to execute the program. */
1738 data to the process. We don't support using different coding 1736 tem = Fcons (ENCODE_FILE (tem), Qnil);
1739 systems for encoding arguments and for encoding data sent to the 1737
1740 process. */ 1738 /* Here we encode arguments by the coding system used for sending
1741 1739 data to the process. We don't support using different coding
1742 for (i = 3; i < nargs; i++) 1740 systems for encoding arguments and for encoding data sent to the
1743 { 1741 process. */
1744 tem = args[i]; 1742
1745 CHECK_STRING (tem); 1743 for (i = 3; i < nargs; i++)
1746 if (STRING_MULTIBYTE (tem)) 1744 {
1747 tem = (code_convert_string_norecord 1745 tem = Fcons (args[i], tem);
1748 (tem, XPROCESS (proc)->encode_coding_system, 1)); 1746 CHECK_STRING (XCAR (tem));
1749 new_argv[i - 2] = SDATA (tem); 1747 if (STRING_MULTIBYTE (XCAR (tem)))
1750 } 1748 XSETCAR (tem,
1751 new_argv[i - 2] = 0; 1749 code_convert_string_norecord
1750 (XCAR (tem), XPROCESS (proc)->encode_coding_system, 1));
1751 }
1752
1753 UNGCPRO;
1754 }
1755
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--)
1762 {
1763 new_argv[i] = SDATA (XCAR (tem));
1764 tem = XCDR (tem);
1765 }
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;
1755 XPROCESS (proc)->encoding_buf = make_uninit_string (0); 1769 XPROCESS (proc)->encoding_buf = make_uninit_string (0);
1756 1770