summaryrefslogtreecommitdiff
path: root/src/callproc.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2014-09-07 20:04:19 +0300
committerEli Zaretskii <eliz@gnu.org>2014-09-07 20:04:19 +0300
commit970d21e8e6aa7e5bafd3f025f66d694b5ae06ba5 (patch)
tree690c29d0085614634903845e267a6fd6c9721818 /src/callproc.c
parent2b95a8efed84d6ec8f178a3bfbbcbfdee3ab35ef (diff)
downloademacs-970d21e8e6aa7e5bafd3f025f66d694b5ae06ba5.tar.gz
Fix the MS-Windows build broken by SAFE_ALLOCA changes.
src/callproc.c (child_setup) [WINDOWSNT]: Don't call exec_failed if 'alloca' gets passed arguments larger than MAX_ALLOCA. src/font.c (MAX): Define if not defined elsewhere.
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 0636571b26c..271743021b6 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1213,8 +1213,13 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
on that. */
pwd_var = xmalloc (i + 5);
#else
+ /* WINDOWSNT doesn't define exec_failed, and doesn't need this
+ test, since a directory name cannot be longer than 260
+ characters, i.e. 260 * 4 = 1040 UTF-8 bytes. */
+#ifndef WINDOWSNT
if (MAX_ALLOCA - 5 < i)
exec_failed (new_argv[0], ENOMEM);
+#endif
pwd_var = alloca (i + 5);
#endif
temp = pwd_var + 4;
@@ -1281,8 +1286,10 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
}
/* new_length + 2 to include PWD and terminating 0. */
+#ifndef WINDOWSNT
if (MAX_ALLOCA / sizeof *env - 2 < new_length)
exec_failed (new_argv[0], ENOMEM);
+#endif
env = new_env = alloca ((new_length + 2) * sizeof *env);
/* If we have a PWD envvar, pass one down,
but with corrected value. */
@@ -1291,9 +1298,14 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
if (STRINGP (display))
{
+ char *vdata;
+
+ /* WINDOWSNT doesn't have $DISPLAY. */
+#ifndef WINDOWSNT
if (MAX_ALLOCA - sizeof "DISPLAY=" < SBYTES (display))
exec_failed (new_argv[0], ENOMEM);
- char *vdata = alloca (sizeof "DISPLAY=" + SBYTES (display));
+#endif
+ vdata = alloca (sizeof "DISPLAY=" + SBYTES (display));
strcpy (vdata, "DISPLAY=");
strcat (vdata, SSDATA (display));
new_env = add_env (env, new_env, vdata);