aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
authorEli Zaretskii2014-09-07 20:04:19 +0300
committerEli Zaretskii2014-09-07 20:04:19 +0300
commit970d21e8e6aa7e5bafd3f025f66d694b5ae06ba5 (patch)
tree690c29d0085614634903845e267a6fd6c9721818 /src/callproc.c
parent2b95a8efed84d6ec8f178a3bfbbcbfdee3ab35ef (diff)
downloademacs-970d21e8e6aa7e5bafd3f025f66d694b5ae06ba5.tar.gz
emacs-970d21e8e6aa7e5bafd3f025f66d694b5ae06ba5.zip
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,
1213 on that. */ 1213 on that. */
1214 pwd_var = xmalloc (i + 5); 1214 pwd_var = xmalloc (i + 5);
1215#else 1215#else
1216 /* WINDOWSNT doesn't define exec_failed, and doesn't need this
1217 test, since a directory name cannot be longer than 260
1218 characters, i.e. 260 * 4 = 1040 UTF-8 bytes. */
1219#ifndef WINDOWSNT
1216 if (MAX_ALLOCA - 5 < i) 1220 if (MAX_ALLOCA - 5 < i)
1217 exec_failed (new_argv[0], ENOMEM); 1221 exec_failed (new_argv[0], ENOMEM);
1222#endif
1218 pwd_var = alloca (i + 5); 1223 pwd_var = alloca (i + 5);
1219#endif 1224#endif
1220 temp = pwd_var + 4; 1225 temp = pwd_var + 4;
@@ -1281,8 +1286,10 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1281 } 1286 }
1282 1287
1283 /* new_length + 2 to include PWD and terminating 0. */ 1288 /* new_length + 2 to include PWD and terminating 0. */
1289#ifndef WINDOWSNT
1284 if (MAX_ALLOCA / sizeof *env - 2 < new_length) 1290 if (MAX_ALLOCA / sizeof *env - 2 < new_length)
1285 exec_failed (new_argv[0], ENOMEM); 1291 exec_failed (new_argv[0], ENOMEM);
1292#endif
1286 env = new_env = alloca ((new_length + 2) * sizeof *env); 1293 env = new_env = alloca ((new_length + 2) * sizeof *env);
1287 /* If we have a PWD envvar, pass one down, 1294 /* If we have a PWD envvar, pass one down,
1288 but with corrected value. */ 1295 but with corrected value. */
@@ -1291,9 +1298,14 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1291 1298
1292 if (STRINGP (display)) 1299 if (STRINGP (display))
1293 { 1300 {
1301 char *vdata;
1302
1303 /* WINDOWSNT doesn't have $DISPLAY. */
1304#ifndef WINDOWSNT
1294 if (MAX_ALLOCA - sizeof "DISPLAY=" < SBYTES (display)) 1305 if (MAX_ALLOCA - sizeof "DISPLAY=" < SBYTES (display))
1295 exec_failed (new_argv[0], ENOMEM); 1306 exec_failed (new_argv[0], ENOMEM);
1296 char *vdata = alloca (sizeof "DISPLAY=" + SBYTES (display)); 1307#endif
1308 vdata = alloca (sizeof "DISPLAY=" + SBYTES (display));
1297 strcpy (vdata, "DISPLAY="); 1309 strcpy (vdata, "DISPLAY=");
1298 strcat (vdata, SSDATA (display)); 1310 strcat (vdata, SSDATA (display));
1299 new_env = add_env (env, new_env, vdata); 1311 new_env = add_env (env, new_env, vdata);