]> code.delx.au - gnu-emacs/commitdiff
Fix the MS-Windows build broken by SAFE_ALLOCA changes.
authorEli Zaretskii <eliz@gnu.org>
Sun, 7 Sep 2014 17:04:19 +0000 (20:04 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 7 Sep 2014 17:04:19 +0000 (20:04 +0300)
 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.

src/ChangeLog
src/callproc.c
src/font.c

index e9c3fe0dea4b6bfaef934b282c9c3e3528a28250..acb8eed47227849f6a124b0de2b5232385782ac1 100644 (file)
@@ -1,3 +1,10 @@
+2014-09-07  Eli Zaretskii  <eliz@gnu.org>
+
+       * callproc.c (child_setup) [WINDOWSNT]: Don't call exec_failed if
+       'alloca' gets passed arguments larger than MAX_ALLOCA.
+
+       * font.c (MAX): Define if not defined elsewhere.
+
 2014-09-07  Paul Eggert  <eggert@cs.ucla.edu>
 
        * keyboard.c (read_decoded_event_from_main_queue): Reinstitute alloca
index 0636571b26c43f4a5f1144db7997b33e16faf69d..271743021b68b7f5661d290969d6cd34c8e9594f 100644 (file)
@@ -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);
index 90a5c6a2f88985c4a0486fc5a96d4fbb4c8f8456..46fc51bd5ad19e923d48ffeb81832b7677424f65 100644 (file)
@@ -41,6 +41,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 
+#ifndef MAX
+# define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
 Lisp_Object Qopentype;
 
 /* Important character set strings.  */