changeset 30530:861a1460eba6

(child_setup) [MSDOS]: malloc pwd_var instead of using alloca; free it after run_msdos_command returns
author Eli Zaretskii <eliz@gnu.org>
date Mon, 31 Jul 2000 06:29:29 +0000
parents 788ce16426e3
children 181a2490ab9e
files src/callproc.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/callproc.c	Mon Jul 31 06:24:21 2000 +0000
+++ b/src/callproc.c	Mon Jul 31 06:29:29 2000 +0000
@@ -1072,7 +1072,14 @@
     register int i;
 
     i = STRING_BYTES (XSTRING (current_dir));
+#ifdef MSDOS
+    /* MSDOS must have all environment variables malloc'ed, because
+       low-level libc functions that launch subsidiary processes rely
+       on that.  */
+    pwd_var = (char *) xmalloc (i + 6);
+#else
     pwd_var = (char *) alloca (i + 6);
+#endif
     temp = pwd_var + 4;
     bcopy ("PWD=", pwd_var, 4);
     bcopy (XSTRING (current_dir)->data, temp, i);
@@ -1212,6 +1219,7 @@
 
 #ifdef MSDOS
   pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env);
+  free (pwd_var);
   if (pid == -1)
     /* An error occurred while trying to run the subprocess.  */
     report_file_error ("Spawning child process", Qnil);