]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Use allocsa and xallocsa, for safer stack allocation.
authorBruno Haible <bruno@clisp.org>
Fri, 19 Dec 2003 11:31:29 +0000 (11:31 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:32 +0000 (12:11 +0200)
33 files changed:
ChangeLog
config/install-reloc
gettext-runtime/ChangeLog
gettext-runtime/configure.ac
gettext-tools/ChangeLog
gettext-tools/configure.ac
gettext-tools/lib/ChangeLog
gettext-tools/lib/Makefile.am
gettext-tools/lib/Makefile.msvc
gettext-tools/lib/Makefile.vms
gettext-tools/lib/canonicalize.c
gettext-tools/lib/javacomp.c
gettext-tools/lib/javaexec.c
gettext-tools/lib/relocwrapper.c
gettext-tools/lib/setenv.c
gettext-tools/m4/ChangeLog
gettext-tools/m4/Makefile.am
gettext-tools/m4/setenv.m4
gettext-tools/src/ChangeLog
gettext-tools/src/format-java.c
gettext-tools/src/msggrep.c
gettext-tools/src/msginit.c
gettext-tools/src/msgl-cat.c
gettext-tools/src/msgl-charset.c
gettext-tools/src/msgl-iconv.c
gettext-tools/src/po-charset.c
gettext-tools/src/read-tcl.c
gettext-tools/src/write-java.c
gettext-tools/src/write-mo.c
gettext-tools/src/write-po.c
gettext-tools/src/write-tcl.c
gettext-tools/src/xgettext.c
gettext-tools/windows/gettextlib.def

index afcb752257b91ee815125d00da40284ee0e06f22..537445c0e4d2ca9e17106bc4063b05fab40abd96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-11-30  Bruno Haible  <bruno@clisp.org>
+
+       * config/install-reloc: Compile also the allocsa.c file.
+
 2003-12-17  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.13.1 released.
index 8d5cc64dcc7b34119c0ef62229576de316fea3b2..ad4b0ebdd6a140d1d9af47d8df4ed67aeae5c137 100755 (executable)
@@ -110,7 +110,7 @@ test -n "$libdirs" || exit 0
 
 # Compile wrapper.
 installdir=`echo "$destprog" | sed -e 's,/[^/]*$,,'`
-func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/readlink.c "$srcdir"/canonicalize.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o $destprog.wrapper || exit $?
+func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/readlink.c "$srcdir"/canonicalize.c "$srcdir"/allocsa.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o $destprog.wrapper || exit $?
 
 # Rename $destprog.wrapper -> $destprog -> $destprog.bin.
 ln -f $destprog $destprog.bin || exit 1
index 066457a02a95678d7a2457b5c901af7155d9cfd9..f9cb83e4710af54c43c7bc9e9910f8efa5e91cca 100644 (file)
@@ -1,3 +1,7 @@
+2003-11-30  Bruno Haible  <bruno@clisp.org>
+
+       * configure.ac: Invoke gl_ALLOCSA instead of gl_FUNC_ALLOCA.
+
 2003-12-17  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.13.1 released.
index 01878e73458c985b5c2e6f5e9a672519205c4efb..b733786d3d8e436a6766cdd92c1943224fb89bf3 100644 (file)
@@ -74,7 +74,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_SIZE_T
 
 dnl Checks for library functions.
-gl_FUNC_ALLOCA
+gl_ALLOCSA
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([setlocale strerror strtoul])
 AC_REPLACE_FUNCS([atexit memmove])
index 82a546a90a683c34dcbf12ad43b63b7e6e18ef4b..fd5861290b0e418a3de9a029d9aea20b825e1c5e 100644 (file)
@@ -1,3 +1,8 @@
+2003-11-30  Bruno Haible  <bruno@clisp.org>
+
+       * configure.ac: Invoke gl_ALLOCSA instead of gl_FUNC_ALLOCA.
+       * windows/gettextlib.def: Add mallocsa, xmallocsa, freesa.
+
 2003-12-17  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.13.1 released.
index 565e61c8cf45dc1c411a5bddd6ff1d7e94b6aa50..64da59d1bad32eb488698db1b73863a09669fa96 100644 (file)
@@ -101,7 +101,7 @@ AC_TYPE_MODE_T
 gt_TYPE_SIG_ATOMIC_T
 
 dnl Checks for library functions.
-gl_FUNC_ALLOCA
+gl_ALLOCSA
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([chown getcwd posix_spawn raise select strerror strtoul uname \
 utime utimes waitid])
index 4c7b0d8bf30c0dbfaac5db266dcc81a9741b30d4..d138b8c725062405380303be0235b52259ebe4ce 100644 (file)
@@ -1,3 +1,30 @@
+2003-11-30  Bruno Haible  <bruno@clisp.org>
+
+       Safer stack allocation.
+       * allocsa.h: New file.
+       * allocsa.c: New file.
+       * xallocsa.h: New file.
+       * xallocsa.c: New file.
+       * canonicalize.c: Include allocsa.h.
+       (__realpath): Use allocsa instead of alloca. Don't clobber errno right
+       before returning NULL.
+       * javacomp.c: Include xallocsa.h.
+       (compile_java_class): Use allocsa instead of alloca.
+       * javaexec.c: Include xallocsa.h.
+       (execute_java_class): Use allocsa instead of alloca.
+       * relocwrapper.c: Indirectly depends on allocsa.
+       * setenv.c: Include allocsa.h.
+       (alloca): Remove fallback definition.
+       (freea): Remove macro.
+       (__add_to_environ) [!_LIBC]: Use allocsa instead of alloca. Use freesa
+       instead of freea.
+       * Makefile.am (libgettextlib_la_SOURCES): Add allocsa.h, allocsa.c,
+       xallocsa.h, xallocsa.c.
+       * Makefile.msvc (OBJECTS): Add allocsa.obj, xallocsa.obj.
+       (allocsa.obj, xallocsa.obj): New rules.
+       * Makefile.vms (OBJECTS): Add allocsa.obj, xallocsa.obj.
+       (allocsa.obj, xallocsa.obj): New rules.
+
 2003-12-17  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.13.1 released.
index fe2aedfc0f5a9bea022f994661cd241eb311ca5f..85e23cb73b5435d9419a9dbfcd31a4e2ded6e26e 100644 (file)
@@ -31,6 +31,7 @@ lib_LTLIBRARIES = libgettextlib.la
 # Sources that are compiled on all platforms.
 
 libgettextlib_la_SOURCES = \
+  allocsa.h allocsa.c \
   argmatch.h argmatch.c \
   backupfile.h backupfile.c addext.c \
   basename.h basename.c \
@@ -71,6 +72,7 @@ libgettextlib_la_SOURCES = \
   unlocked-io.h \
   wait-process.h wait-process.c \
   xalloc.h xmalloc.c xstrdup.c \
+  xallocsa.h xallocsa.c \
   xerror.h xerror.c \
   xreadlink.h xreadlink.c \
   xsetenv.h xsetenv.c \
index 3e22de864ea4766f17654724a1ee7f52572a285f..11b35c212dc08610ef46635e5e1b3c2e1b4194f1 100644 (file)
@@ -80,6 +80,7 @@ INSTALL_DATA = copy
 SHELL = /bin/sh
 
 OBJECTS = \
+  allocsa.obj \
   argmatch.obj \
   backupfile.obj addext.obj \
   basename.obj \
@@ -114,6 +115,7 @@ OBJECTS = \
   tmpdir.obj \
   wait-process.obj \
   xmalloc.obj xstrdup.obj \
+  xallocsa.obj \
   xerror.obj \
   xsetenv.obj \
   \
@@ -131,6 +133,9 @@ RESOURCES = gettextlib.res
 
 all : gettextlib.lib
 
+allocsa.obj : allocsa.c
+       $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c allocsa.c
+
 argmatch.obj : argmatch.c
        $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c argmatch.c
 
@@ -251,6 +256,9 @@ xmalloc.obj : xmalloc.c
 xstrdup.obj : xstrdup.c
        $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c xstrdup.c
 
+xallocsa.obj : xallocsa.c
+       $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c xallocsa.c
+
 xerror.obj : xerror.c
        $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c xerror.c
 
index df74b4a003255e95c1009195f36fd61fd6f91aef..2872dbc0ded9f6af71df036960b3d0d7563f2574 100644 (file)
@@ -38,6 +38,7 @@ INSTALL_DATA = copy
 #### End of system configuration section. ####
 
 OBJECTS = \
+  allocsa.obj, \
   argmatch.obj, \
   backupfile.obj, addext.obj, \
   basename.obj, \
@@ -72,6 +73,7 @@ OBJECTS = \
   tmpdir.obj, \
   wait-process.obj, \
   xmalloc.obj, xstrdup.obj, \
+  xallocsa.obj, \
   xerror.obj, \
   xsetenv.obj, \
   \
@@ -92,6 +94,9 @@ alloca.h : alloca_.h
 fnmatch.h : fnmatch_.h
        $(LN) fnmatch_.h fnmatch.h
 
+allocsa.obj : allocsa.c
+       $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) allocsa.c
+
 argmatch.obj : argmatch.c
        $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) argmatch.c
 
@@ -212,6 +217,9 @@ xmalloc.obj : xmalloc.c
 xstrdup.obj : xstrdup.c
        $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) xstrdup.c
 
+xallocsa.obj : xallocsa.c
+       $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) xallocsa.c
+
 xerror.obj : xerror.c
        $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) xerror.c
 
index 336843ddd31a2fe3ec9580b522ddf9297194e5e6..fe0cb6d82c3137f2d1db2f110462e482b507cebe 100644 (file)
@@ -69,7 +69,7 @@
 # define __canonicalize_file_name canonicalize_file_name
 # define __realpath rpl_realpath
 # include "pathmax.h"
-# define __alloca alloca
+# include "allocsa.h"
 # if HAVE_GETCWD
 #  ifdef VMS
     /* We want the directory in Unix syntax, not in VMS syntax.  */
@@ -236,7 +236,7 @@ __realpath (const char *name, char *resolved)
 #ifdef S_ISLNK
          if (S_ISLNK (st.st_mode))
            {
-             char *buf = __alloca (path_max);
+             char *buf;
              size_t len;
 
              if (++num_links > MAXSYMLINKS)
@@ -245,17 +245,38 @@ __realpath (const char *name, char *resolved)
                  goto error;
                }
 
+             buf = allocsa (path_max);
+             if (!buf)
+               {
+                 errno = ENOMEM;
+                 goto error;
+               }
+
              n = __readlink (rpath, buf, path_max);
              if (n < 0)
-               goto error;
+               {
+                 int saved_errno = errno;
+                 freesa (buf);
+                 errno = saved_errno;
+                 goto error;
+               }
              buf[n] = '\0';
 
              if (!extra_buf)
-               extra_buf = __alloca (path_max);
+               {
+                 extra_buf = allocsa (path_max);
+                 if (!extra_buf)
+                   {
+                     freesa (buf);
+                     errno = ENOMEM;
+                     goto error;
+                   }
+               }
 
              len = strlen (end);
              if ((long int) (n + len) >= path_max)
                {
+                 freesa (buf);
                  __set_errno (ENAMETOOLONG);
                  goto error;
                }
@@ -278,13 +299,22 @@ __realpath (const char *name, char *resolved)
     --dest;
   *dest = '\0';
 
+  if (extra_buf)
+    freesa (extra_buf);
+
   return resolved ? memcpy (resolved, rpath, dest - rpath + 1) : rpath;
 
 error:
-  if (resolved)
-    strcpy (resolved, rpath);
-  else
-    free (rpath);
+  {
+    int saved_errno = errno;
+    if (extra_buf)
+      freesa (extra_buf);
+    if (resolved)
+      strcpy (resolved, rpath);
+    else
+      free (rpath);
+    errno = saved_errno;
+  }
   return NULL;
 }
 #ifdef _LIBC
index 6f50a1d8293c14747c5576bc29e62e0f0e01fbcb..16aeaf8780e7d30f0f19b46fc954965cf545cce8 100644 (file)
@@ -36,6 +36,7 @@
 #include "sh-quote.h"
 #include "safe-read.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "error.h"
 #include "gettext.h"
 
@@ -122,7 +123,7 @@ compile_java_class (const char * const *java_sources,
          command_length += 1 + shell_quote_length (java_sources[i]);
        command_length += 1;
 
-       command = (char *) alloca (command_length);
+       command = (char *) xallocsa (command_length);
        p = command;
        /* Don't shell_quote $JAVAC, because it may consist of a command
           and options.  */
@@ -165,6 +166,8 @@ compile_java_class (const char * const *java_sources,
                              true, true);
        err = (exitstatus != 0);
 
+       freesa (command);
+
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
@@ -263,7 +266,7 @@ compile_java_class (const char * const *java_sources,
        argc =
          2 + (optimize ? 1 : 0) + (debug ? 1 : 0) + (directory != NULL ? 2 : 0)
          + java_sources_count;
-       argv = (char **) alloca ((argc + 1) * sizeof (char *));
+       argv = (char **) xallocsa ((argc + 1) * sizeof (char *));
 
        argp = argv;
        *argp++ = "gcj";
@@ -295,6 +298,8 @@ compile_java_class (const char * const *java_sources,
                              true);
        err = (exitstatus != 0);
 
+       freesa (argv);
+
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
@@ -339,7 +344,7 @@ compile_java_class (const char * const *java_sources,
        argc =
          1 + (optimize ? 1 : 0) + (debug ? 1 : 0) + (directory != NULL ? 2 : 0)
          + java_sources_count;
-       argv = (char **) alloca ((argc + 1) * sizeof (char *));
+       argv = (char **) xallocsa ((argc + 1) * sizeof (char *));
 
        argp = argv;
        *argp++ = "javac";
@@ -370,6 +375,8 @@ compile_java_class (const char * const *java_sources,
                              true, true);
        err = (exitstatus != 0);
 
+       freesa (argv);
+
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
@@ -416,7 +423,7 @@ compile_java_class (const char * const *java_sources,
        argc =
          1 + (optimize ? 1 : 0) + (debug ? 1 : 0) + (directory != NULL ? 2 : 0)
          + java_sources_count;
-       argv = (char **) alloca ((argc + 1) * sizeof (char *));
+       argv = (char **) xallocsa ((argc + 1) * sizeof (char *));
 
        argp = argv;
        *argp++ = "jikes";
@@ -447,6 +454,8 @@ compile_java_class (const char * const *java_sources,
                              true, true);
        err = (exitstatus != 0);
 
+       freesa (argv);
+
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
index ab218de325697b10454e86b0500811389087467d..0f56840b70a1e034c7fa845f6f35ae985e4ac1fa 100644 (file)
@@ -34,6 +34,7 @@
 #include "sh-quote.h"
 #include "pathname.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "error.h"
 #include "gettext.h"
 
@@ -98,7 +99,7 @@ execute_java_class (const char *class_name,
     {
       char *exe_pathname = concatenated_pathname (exe_dir, class_name, EXEEXT);
       char *old_classpath;
-      char **argv = (char **) alloca ((1 + nargs + 1) * sizeof (char *));
+      char **argv = (char **) xallocsa ((1 + nargs + 1) * sizeof (char *));
       unsigned int i;
 
       /* Set CLASSPATH.  */
@@ -122,6 +123,8 @@ execute_java_class (const char *class_name,
       /* Reset CLASSPATH.  */
       reset_classpath (old_classpath);
 
+      freesa (argv);
+
       goto done1;
     }
 
@@ -151,7 +154,7 @@ execute_java_class (const char *class_name,
          command_length += 1 + shell_quote_length (*arg);
        command_length += 1;
 
-       command = (char *) alloca (command_length);
+       command = (char *) xallocsa (command_length);
        p = command;
        /* Don't shell_quote $JAVA, because it may consist of a command
           and options.  */
@@ -178,6 +181,8 @@ execute_java_class (const char *class_name,
        argv[3] = NULL;
        err = executer (java, "/bin/sh", argv, private_data);
 
+       freesa (command);
+
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
@@ -215,7 +220,7 @@ execute_java_class (const char *class_name,
     if (gij_present)
       {
        char *old_classpath;
-       char **argv = (char **) alloca ((2 + nargs + 1) * sizeof (char *));
+       char **argv = (char **) xallocsa ((2 + nargs + 1) * sizeof (char *));
        unsigned int i;
 
        /* Set CLASSPATH.  */
@@ -240,6 +245,8 @@ execute_java_class (const char *class_name,
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
+       freesa (argv);
+
        goto done2;
       }
   }
@@ -266,7 +273,7 @@ execute_java_class (const char *class_name,
     if (java_present)
       {
        char *old_classpath;
-       char **argv = (char **) alloca ((2 + nargs + 1) * sizeof (char *));
+       char **argv = (char **) xallocsa ((2 + nargs + 1) * sizeof (char *));
        unsigned int i;
 
        /* Set CLASSPATH.  We don't use the "-classpath ..." option because
@@ -293,6 +300,8 @@ execute_java_class (const char *class_name,
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
+       freesa (argv);
+
        goto done2;
       }
   }
@@ -318,7 +327,7 @@ execute_java_class (const char *class_name,
     if (jre_present)
       {
        char *old_classpath;
-       char **argv = (char **) alloca ((2 + nargs + 1) * sizeof (char *));
+       char **argv = (char **) xallocsa ((2 + nargs + 1) * sizeof (char *));
        unsigned int i;
 
        /* Set CLASSPATH.  We don't use the "-classpath ..." option because
@@ -345,6 +354,8 @@ execute_java_class (const char *class_name,
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
+       freesa (argv);
+
        goto done2;
       }
   }
@@ -373,7 +384,7 @@ execute_java_class (const char *class_name,
     if (jview_present)
       {
        char *old_classpath;
-       char **argv = (char **) alloca ((2 + nargs + 1) * sizeof (char *));
+       char **argv = (char **) xallocsa ((2 + nargs + 1) * sizeof (char *));
        unsigned int i;
 
        /* Set CLASSPATH.  */
@@ -398,6 +409,8 @@ execute_java_class (const char *class_name,
        /* Reset CLASSPATH.  */
        reset_classpath (old_classpath);
 
+       freesa (argv);
+
        goto done2;
       }
   }
index 684442c949fb11b9fc61fa2f9772937d16266092..c4002f8102bcca276c40333d821e82193fc45fc3 100644 (file)
         -> xreadlink
            -> readlink
         -> canonicalize
+           -> allocsa
     -> relocatable
     -> setenv
+       -> allocsa
     -> strerror
 
    Macros that need to be set while compiling this file:
index 7c8ab7a3e1281251b9131da329862a50b7a2c685..f2082cdbe9d517f5d614c32e8e63a84a34613b39 100644 (file)
@@ -39,13 +39,8 @@ extern int errno;
 # include <unistd.h>
 #endif
 
-/* For those losing systems which don't have 'alloca' we have to add
-   some additional code emulating it.  */
-#if _LIBC || HAVE_ALLOCA
-# define freea(p) /* nothing */
-#else
-# define alloca(n) malloc (n)
-# define freea(p) free (p)
+#if !_LIBC
+# include "allocsa.h"
 #endif
 
 #if !_LIBC
@@ -168,11 +163,18 @@ __add_to_environ (const char *name, const char *value, const char *combined,
        {
          /* See whether the value is already known.  */
 #ifdef USE_TSEARCH
-         new_value = (char *) alloca (namelen + 1 + vallen);
 # ifdef _LIBC
+         new_value = (char *) alloca (namelen + 1 + vallen);
          __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
                     value, vallen);
 # else
+         new_value = (char *) allocsa (namelen + 1 + vallen);
+         if (new_value == NULL)
+           {
+             __set_errno (ENOMEM);
+             UNLOCK;
+             return -1;
+           }
          memcpy (new_value, name, namelen);
          new_value[namelen] = '=';
          memcpy (&new_value[namelen + 1], value, vallen);
@@ -185,8 +187,8 @@ __add_to_environ (const char *name, const char *value, const char *combined,
              new_environ[size] = (char *) malloc (namelen + 1 + vallen);
              if (new_environ[size] == NULL)
                {
-#ifdef USE_TSEARCH
-                 freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+                 freesa (new_value);
 #endif
                  __set_errno (ENOMEM);
                  UNLOCK;
@@ -205,8 +207,8 @@ __add_to_environ (const char *name, const char *value, const char *combined,
                 user string or not.  */
              STORE_VALUE (new_environ[size]);
            }
-#ifdef USE_TSEARCH
-         freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+         freesa (new_value);
 #endif
        }
 
@@ -228,11 +230,19 @@ __add_to_environ (const char *name, const char *value, const char *combined,
       else
        {
 #ifdef USE_TSEARCH
-         char *new_value = alloca (namelen + 1 + vallen);
+         char *new_value;
 # ifdef _LIBC
+         new_value = alloca (namelen + 1 + vallen);
          __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
                     value, vallen);
 # else
+         new_value = allocsa (namelen + 1 + vallen);
+         if (new_value == NULL)
+           {
+             __set_errno (ENOMEM);
+             UNLOCK;
+             return -1;
+           }
          memcpy (new_value, name, namelen);
          new_value[namelen] = '=';
          memcpy (&new_value[namelen + 1], value, vallen);
@@ -245,9 +255,10 @@ __add_to_environ (const char *name, const char *value, const char *combined,
              np = malloc (namelen + 1 + vallen);
              if (np == NULL)
                {
-#ifdef USE_TSEARCH
-                 freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+                 freesa (new_value);
 #endif
+                 __set_errno (ENOMEM);
                  UNLOCK;
                  return -1;
                }
@@ -262,8 +273,8 @@ __add_to_environ (const char *name, const char *value, const char *combined,
              /* And remember the value.  */
              STORE_VALUE (np);
            }
-#ifdef USE_TSEARCH
-         freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+         freesa (new_value);
 #endif
        }
 
index 8c487075f99fe8eeda845370f790f42cdb12f519..6f1ac94eda358957e172e2dcc974978e545ab576 100644 (file)
@@ -1,3 +1,11 @@
+2003-11-30  Bruno Haible  <bruno@clisp.org>
+
+       * allocsa.m4: New file.
+       * eealloc.m4: New file.
+       * setenv.m4 (gl_PREREQ_SETENV): Require gl_ALLOCSA instead of
+       AC_FUNC_ALLOCA.
+       * Makefile.am (EXTRA_DIST): Add allocsa.m4, eealloc.m4.
+
 2003-12-17  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.13.1 released.
index 8c6fdea1c2fa954be8110f7ca8f4025271598b4f..9e8f990738ff04379c346353ce492364994bbf9b 100644 (file)
@@ -43,9 +43,11 @@ examplesconfig_DATA = gcj.m4 javacomp.m4 javaexec.m4
 # find . -type f -name '*.m4' -printf '%f\n' | sort | tr '\012' @ | sed 's/@$/%/;s/@/ \\@/g' | tr @% '\012\012'
 EXTRA_DIST = README ChangeLog.0 \
 alloca.m4 \
+allocsa.m4 \
 backupfile.m4 \
 canonicalize.m4 \
 eaccess.m4 \
+eealloc.m4 \
 error.m4 \
 extensions.m4 \
 fnmatch.m4 \
index af621ec53ea549b6c0fd6428b7598bb2c7a319e0..6c3058981b157608305f7b23f3326e2eb0762f43 100644 (file)
@@ -1,5 +1,5 @@
-# setenv.m4 serial 3
-dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
+# setenv.m4 serial 4
+dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -39,7 +39,7 @@ AC_DEFUN([gt_CHECK_VAR_DECL],
 # Prerequisites of lib/setenv.c.
 AC_DEFUN([gl_PREREQ_SETENV],
 [
-  AC_REQUIRE([AC_FUNC_ALLOCA])
+  AC_REQUIRE([gl_ALLOCSA])
   AC_CHECK_HEADERS_ONCE(stdlib.h string.h unistd.h)
   AC_CHECK_HEADERS(search.h)
   AC_CHECK_FUNCS(tsearch)
index b9e66b9f765d392b69ad2ce1f3134f855a6b35fd..598cba856ecfe10a00ea72d2a8ca9fd22537394b 100644 (file)
@@ -1,3 +1,37 @@
+2003-11-30  Bruno Haible  <bruno@clisp.org>
+
+       * format-java.c: Include xallocsa.h.
+       (message_format_parse): Use xallocsa instead of alloca.
+       (choice_format_parse): Likewise.
+       * msgl-cat.c: Include xallocsa.h.
+       (catenate_msgdomain_list): Use xallocsa instead of alloca.
+       * msgl-charset.c: Include xallocsa.h.
+       (compare_po_locale_charsets): Use xallocsa instead of alloca.
+       * msgl-iconv.c: Include xallocsa.h.
+       (iconv_message_list): Use xallocsa instead of alloca.
+       * po-charset.c: Include xallocsa.h.
+       (po_lex_charset_set): Use xallocsa instead of alloca.
+       * read-tcl.c: Include xallocsa.h.
+       (msgdomain_read_tcl): Use xallocsa instead of alloca.
+       * write-java.c: Include xallocsa.h.
+       (compute_hashsize, msgdomain_write_java): Use xallocsa instead of
+       alloca.
+       * write-mo.c: Include xallocsa.h.
+       (write_table): Use xallocsa instead of alloca.
+       * write-po.c: Include xallocsa.h.
+       (msgdomain_list_print_po): Use xallocsa instead of alloca.
+       * write-tcl.c: Include xallocsa.h.
+       (msgdomain_write_tcl): Use xallocsa instead of alloca.
+       * msggrep.c: Include xallocsa.h.
+       (is_message_selected): Use xallocsa instead of alloca.
+       * msginit.c: Include xallocsa.h.
+       (subst_string): Use xallocsa instead of alloca.
+       * msgmerge.c: Include obstack.h.
+       (obstack_chunk_alloc, obstack_chunk_free): New macros.
+       (message_merge): Use obstack_alloc instead of alloca.
+       * xgettext.c: Include xallocsa.h.
+       (flag_context_list_table_insert): Use xallocsa instead of alloca.
+
 2003-12-17  Bruno Haible  <bruno@clisp.org>
 
        * gettext-0.13.1 released.
index 74256876be5ae895d79cd44c58a1f0e930de1418..c8b9535fc14f1afc7273960b37f1f9e5049c4691 100644 (file)
@@ -28,6 +28,7 @@
 #include "format.h"
 #include "c-ctype.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "xerror.h"
 #include "format-invalid.h"
 #include "error.h"
@@ -193,7 +194,7 @@ message_format_parse (const char *format, struct spec *spec,
          element_end = format++;
 
          n = element_end - element_start;
-         element = (char *) alloca (n + 1);
+         element = (char *) xallocsa (n + 1);
          memcpy (element, element_start, n);
          element[n] = '\0';
 
@@ -201,6 +202,7 @@ message_format_parse (const char *format, struct spec *spec,
            {
              *invalid_reason =
                xasprintf (_("In the directive number %u, '{' is not followed by an argument number."), spec->directives);
+             freesa (element);
              return false;
            }
          number = 0;
@@ -234,6 +236,7 @@ message_format_parse (const char *format, struct spec *spec,
                    {
                      *invalid_reason =
                        xasprintf (_("In the directive number %u, the substring \"%s\" is not a valid date/time style."), spec->directives, element);
+                     freesa (element);
                      return false;
                    }
                }
@@ -243,6 +246,7 @@ message_format_parse (const char *format, struct spec *spec,
                  element -= 4;
                  *invalid_reason =
                    xasprintf (_("In the directive number %u, \"%s\" is not followed by a comma."), spec->directives, element);
+                 freesa (element);
                  return false;
                }
            }
@@ -264,6 +268,7 @@ message_format_parse (const char *format, struct spec *spec,
                    {
                      *invalid_reason =
                        xasprintf (_("In the directive number %u, the substring \"%s\" is not a valid number style."), spec->directives, element);
+                     freesa (element);
                      return false;
                    }
                }
@@ -273,6 +278,7 @@ message_format_parse (const char *format, struct spec *spec,
                  element -= 6;
                  *invalid_reason =
                    xasprintf (_("In the directive number %u, \"%s\" is not followed by a comma."), spec->directives, element);
+                 freesa (element);
                  return false;
                }
            }
@@ -288,7 +294,10 @@ message_format_parse (const char *format, struct spec *spec,
                  if (choice_format_parse (element, spec, invalid_reason))
                    ;
                  else
-                   return false;
+                   {
+                     freesa (element);
+                     return false;
+                   }
                }
              else
                {
@@ -296,6 +305,7 @@ message_format_parse (const char *format, struct spec *spec,
                  element -= 6;
                  *invalid_reason =
                    xasprintf (_("In the directive number %u, \"%s\" is not followed by a comma."), spec->directives, element);
+                 freesa (element);
                  return false;
                }
            }
@@ -303,8 +313,10 @@ message_format_parse (const char *format, struct spec *spec,
            {
              *invalid_reason =
                xasprintf (_("In the directive number %u, the argument number is not followed by a comma and one of \"%s\", \"%s\", \"%s\", \"%s\"."), spec->directives, "time", "date", "number", "choice");
+             freesa (element);
              return false;
            }
+         freesa (element);
 
          if (spec->allocated == spec->numbered_arg_count)
            {
@@ -511,6 +523,7 @@ choice_format_parse (const char *format, struct spec *spec,
       bool number_nonempty;
       char *msgformat;
       char *mp;
+      bool msgformat_valid;
 
       /* Parse number.  */
       number_nonempty = false;
@@ -559,7 +572,7 @@ choice_format_parse (const char *format, struct spec *spec,
        }
       HANDLE_QUOTE;
 
-      msgformat = (char *) alloca (strlen (format) + 1);
+      msgformat = (char *) xallocsa (strlen (format) + 1);
       mp = msgformat;
 
       while (*format != '\0' && !(!quoting && *format == '|'))
@@ -569,7 +582,11 @@ choice_format_parse (const char *format, struct spec *spec,
        }
       *mp = '\0';
 
-      if (!message_format_parse (msgformat, spec, invalid_reason))
+      msgformat_valid = message_format_parse (msgformat, spec, invalid_reason);
+
+      freesa (msgformat);
+
+      if (!msgformat_valid)
        return false;
 
       if (*format == '\0')
index 0b5c29b942b0ccd2a4a5ebecb1b2dcd5c3874982..767627016874d9f1e86121ee7567b37f29eeb6e1 100644 (file)
@@ -51,6 +51,7 @@
 #include "str-list.h"
 #include "msgl-charset.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "exit.h"
 #include "full-write.h"
 #include "findprog.h"
@@ -659,11 +660,12 @@ is_message_selected (const message_ty *mp)
       char *total_comment;
       char *q;
       size_t j;
+      bool selected;
 
       length = 0;
       for (j = 0; j < mp->comment->nitems; j++)
        length += strlen (mp->comment->item[j]) + 1;
-      total_comment = (char *) alloca (length);
+      total_comment = (char *) xallocsa (length);
 
       q = total_comment;
       for (j = 0; j < mp->comment->nitems; j++)
@@ -677,7 +679,11 @@ is_message_selected (const message_ty *mp)
       if (q != total_comment + length)
        abort ();
 
-      if (is_string_selected (2, total_comment, length))
+      selected = is_string_selected (2, total_comment, length);
+
+      freesa (total_comment);
+
+      if (selected)
        return true;
     }
 
index 45e2554c513481a3ba96e0fb0942ed796a2553aa..0aa4418c59aebe5cddb3e4bda51c185fd529f501 100644 (file)
@@ -86,6 +86,7 @@
 #include "po-time.h"
 #include "plural-table.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "exit.h"
 #include "pathname.h"
 #include "xerror.h"
@@ -1581,7 +1582,7 @@ subst_string (const char *str,
       size_t i;
       unsigned int j;
 
-      substlen = (size_t *) alloca (nsubst * sizeof (size_t));
+      substlen = (size_t *) xallocsa (nsubst * sizeof (size_t));
       for (j = 0; j < nsubst; j++)
        {
          substlen[j] = strlen (subst[j][0]);
@@ -1613,6 +1614,8 @@ subst_string (const char *str,
          if (j == nsubst)
            i++;
        }
+
+      freesa (substlen);
     }
 
   return str;
index c6d9742b00c6a6cc20840c91f2f1d0de341a5fe1..902bd6ec9ab9917577313df234407c915868db92 100644 (file)
@@ -38,6 +38,7 @@
 #include "msgl-equal.h"
 #include "msgl-iconv.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "strstr.h"
 #include "basename.h"
 #include "exit.h"
@@ -152,7 +153,7 @@ catenate_msgdomain_list (string_list_ty *file_list, const char *to_code)
 
                            charsetstr += strlen ("charset=");
                            len = strcspn (charsetstr, " \t\n");
-                           charset = (char *) alloca (len + 1);
+                           charset = (char *) xallocsa (len + 1);
                            memcpy (charset, charsetstr, len);
                            charset[len] = '\0';
 
@@ -177,6 +178,8 @@ present charset \"%s\" is not a portable encoding name"),
                                         charset);
                              }
 
+                           freesa (charset);
+
                            if (canon_from_code == NULL)
                              canon_from_code = canon_charset;
                            else if (canon_from_code != canon_charset)
index 582193cf209a7a6dfbc03c9b051bed333b88e7bb..114f877e1a22d11627508e1052fac84af0fd8b8b 100644 (file)
@@ -33,6 +33,7 @@
 #include "error.h"
 #include "progname.h"
 #include "basename.h"
+#include "xallocsa.h"
 #include "xerror.h"
 #include "message.h"
 #include "strstr.h"
@@ -75,7 +76,7 @@ compare_po_locale_charsets (const msgdomain_list_ty *mdlp)
 
                    charsetstr += strlen ("charset=");
                    len = strcspn (charsetstr, " \t\n");
-                   charset = (char *) alloca (len + 1);
+                   charset = (char *) xallocsa (len + 1);
                    memcpy (charset, charsetstr, len);
                    charset[len] = '\0';
 
@@ -85,6 +86,7 @@ compare_po_locale_charsets (const msgdomain_list_ty *mdlp)
                             _("\
 present charset \"%s\" is not a portable encoding name"),
                             charset);
+                   freesa (charset);
                    if (canon_locale_code != canon_charset)
                      {
                        multiline_warning (xasprintf (_("warning: ")),
index 5eb99ff58d0808412b3a25c0b44bda05b8fd1df0..d5f93b7efb7c87bc23c7f1e53ef80290be9a8d19 100644 (file)
@@ -41,6 +41,7 @@
 #include "po-charset.h"
 #include "msgl-ascii.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "strstr.h"
 #include "exit.h"
 #include "gettext.h"
@@ -279,7 +280,7 @@ iconv_message_list (message_list_ty *mlp,
 
                charsetstr += strlen ("charset=");
                len = strcspn (charsetstr, " \t\n");
-               charset = (char *) alloca (len + 1);
+               charset = (char *) xallocsa (len + 1);
                memcpy (charset, charsetstr, len);
                charset[len] = '\0';
 
@@ -316,6 +317,7 @@ present charset \"%s\" is not a portable encoding name"),
 two different charsets \"%s\" and \"%s\" in input file"),
                             canon_from_code, canon_charset);
                  }
+               freesa (charset);
 
                len1 = charsetstr - header;
                len2 = strlen (canon_to_code);
index 33023ee43c885a2f140f7311273868f5f1aef218..4399a8607965e8ff52567a93fbbae4d5e1b5271c 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "xallocsa.h"
 #include "xerror.h"
 #include "basename.h"
 #include "progname.h"
@@ -207,7 +208,7 @@ po_lex_charset_set (const char *header_entry, const char *filename)
 
       charsetstr += strlen ("charset=");
       len = strcspn (charsetstr, " \t\n");
-      charset = (char *) alloca (len + 1);
+      charset = (char *) xallocsa (len + 1);
       memcpy (charset, charsetstr, len);
       charset[len] = '\0';
 
@@ -336,6 +337,7 @@ would fix this problem.\n")));
 #endif
            }
        }
+      freesa (charset);
     }
   else
     {
index a0dcf2960c9baafb9f1a9fc0f7aac8648edf96ee..4d41678306037bf7982df47f0d0be523b959851c 100644 (file)
@@ -35,6 +35,7 @@
 #include "pipe.h"
 #include "wait-process.h"
 #include "read-po.h"
+#include "xallocsa.h"
 #include "error.h"
 #include "exit.h"
 #include "gettext.h"
@@ -73,7 +74,7 @@ msgdomain_read_tcl (const char *locale_name, const char *directory)
 
   /* Convert the locale name to lowercase and remove any encoding.  */
   len = strlen (locale_name);
-  frobbed_locale_name = (char *) alloca (len + 1);
+  frobbed_locale_name = (char *) xallocsa (len + 1);
   memcpy (frobbed_locale_name, locale_name, len + 1);
   for (p = frobbed_locale_name; *p != '\0'; p++)
     if (*p >= 'A' && *p <= 'Z')
@@ -86,6 +87,8 @@ msgdomain_read_tcl (const char *locale_name, const char *directory)
 
   file_name = concatenated_pathname (directory, frobbed_locale_name, ".msg");
 
+  freesa (frobbed_locale_name);
+
   /* Prepare arguments.  */
   argv[0] = "tclsh";
   argv[1] = tclscript;
index bbf2090ed30ea3ff541c9d7954eb83d8a7cb2f4a..5015bd7d468217f6b2cd34fe3b6225caa4dfb696 100644 (file)
@@ -78,6 +78,7 @@
 #include "plural-exp.h"
 #include "po-charset.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "pathname.h"
 #include "fatal-signal.h"
 #include "fwriteerror.h"
@@ -158,7 +159,8 @@ compute_hashsize (message_list_ty *mlp, bool *collisionp)
 #define XXN 3  /* can be tweaked */
 #define XXS 3  /* can be tweaked */
   unsigned int n = mlp->nitems;
-  unsigned int *hashcodes = (unsigned int *) alloca (n * sizeof (unsigned int));
+  unsigned int *hashcodes =
+    (unsigned int *) xallocsa (n * sizeof (unsigned int));
   unsigned int hashsize;
   unsigned int best_hashsize;
   unsigned int best_score;
@@ -275,6 +277,8 @@ compute_hashsize (message_list_ty *mlp, bool *collisionp)
   if (best_hashsize == 0 || best_score < best_hashsize)
     abort ();
 
+  freesa (hashcodes);
+
   /* There are collisions if and only if best_score > best_hashsize.  */
   *collisionp = (best_score > best_hashsize);
   return best_hashsize;
@@ -970,7 +974,7 @@ msgdomain_write_java (message_list_ty *mlp, const char *canon_encoding,
   }
 
   /* Create a temporary directory where we can put the Java file.  */
-  template = (char *) alloca (PATH_MAX);
+  template = (char *) xallocsa (PATH_MAX);
   if (path_search (template, PATH_MAX, NULL, "msg", 1))
     {
       error (0, errno,
@@ -1010,7 +1014,7 @@ msgdomain_write_java (message_list_ty *mlp, const char *canon_encoding,
   else
     class_name = xstrdup (resource_name);
 
-  subdirs = (ndots > 0 ? (char **) alloca (ndots * sizeof (char *)) : NULL);
+  subdirs = (ndots > 0 ? (char **) xallocsa (ndots * sizeof (char *)) : NULL);
   {
     const char *p;
     const char *last_dir;
@@ -1022,10 +1026,11 @@ msgdomain_write_java (message_list_ty *mlp, const char *canon_encoding,
       {
        const char *q = strchr (p, '.');
        size_t n = q - p;
-       char *part = (char *) alloca (n + 1);
+       char *part = (char *) xallocsa (n + 1);
        memcpy (part, p, n);
        part[n] = '\0';
        subdirs[i] = concatenated_pathname (last_dir, part, NULL);
+       freesa (part);
        last_dir = subdirs[i];
        p = q + 1;
       }
@@ -1113,11 +1118,13 @@ compilation of Java class failed, please try --verbose or set $JAVAC"));
     for (i = 0; i < ndots; i++)
       free (subdirs[i]);
   }
+  freesa (subdirs);
   free (class_name);
  quit2:
   rmdir (tmpdir);
  quit1:
   cleanup_list.tmpdir = NULL;
+  freesa (template);
   /* Here we could unregister the cleanup() handler.  */
   return retval;
 }
index f8503072ed0b930787d36fdacd2f7e1391107396..7402c282721c2d52d11ba9f299cd51dcb350775e 100644 (file)
@@ -43,6 +43,7 @@
 #include "message.h"
 #include "format.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "binary-io.h"
 #include "fwriteerror.h"
 #include "exit.h"
@@ -560,8 +561,8 @@ write_table (FILE *output_file, message_list_ty *mlp)
            struct pre_sysdep_string *pre = msg->str[m];
            struct sysdep_string *str =
              (struct sysdep_string *)
-             alloca (sizeof (struct sysdep_string)
-                     + pre->segmentcount * sizeof (struct segment_pair));
+             xallocsa (sizeof (struct sysdep_string)
+                       + pre->segmentcount * sizeof (struct segment_pair));
            unsigned int i;
 
            offset = roundup (offset, alignment);
@@ -582,7 +583,7 @@ write_table (FILE *output_file, message_list_ty *mlp)
                    + pre->segmentcount * sizeof (struct segment_pair),
                    1, output_file);
 
-           freea (str);
+           freesa (str);
          }
     }
 
index 68c02cd013df6be2fe0f904c0101741332709f59..54a9f94e473e7ce7a39cfd4b5da024663b26e74f 100644 (file)
@@ -42,6 +42,7 @@
 #include "write-properties.h"
 #include "write-stringtable.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "strstr.h"
 #include "fwriteerror.h"
 #include "exit.h"
@@ -955,6 +956,7 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, bool debug)
       message_list_ty *mlp;
       const char *header;
       char *charset;
+      char *allocated_charset;
 
       /* If the first domain is the default, don't bother emitting
         the domain name, because it is the default.  */
@@ -980,6 +982,7 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, bool debug)
 
       /* Extract the charset name.  */
       charset = "ASCII";
+      allocated_charset = NULL;
       if (header != NULL)
        {
          const char *charsetstr = strstr (header, "charset=");
@@ -990,7 +993,7 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, bool debug)
 
              charsetstr += strlen ("charset=");
              len = strcspn (charsetstr, " \t\n");
-             charset = (char *) alloca (len + 1);
+             charset = allocated_charset = (char *) xallocsa (len + 1);
              memcpy (charset, charsetstr, len);
              charset[len] = '\0';
 
@@ -1015,6 +1018,9 @@ msgdomain_list_print_po (msgdomain_list_ty *mdlp, FILE *fp, bool debug)
            message_print_obsolete (mlp->item[j], fp, charset, blank_line);
            blank_line = true;
          }
+
+      if (allocated_charset != NULL)
+       freesa (allocated_charset);
     }
 }
 
index 9b8b8f7dffe6961c1e9daeed4301de35166267ed..b75287d77e084a1b370538d297a4daeff803342e 100644 (file)
@@ -35,6 +35,7 @@
 #include "msgl-iconv.h"
 #include "po-charset.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "pathname.h"
 #include "fwriteerror.h"
 #include "exit.h"
@@ -174,7 +175,7 @@ but the Tcl message catalog format doesn't support plural handling\n")));
 
     /* Convert the locale name to lowercase and remove any encoding.  */
     len = strlen (locale_name);
-    frobbed_locale_name = (char *) alloca (len + 1);
+    frobbed_locale_name = (char *) xallocsa (len + 1);
     memcpy (frobbed_locale_name, locale_name, len + 1);
     for (p = frobbed_locale_name; *p != '\0'; p++)
       if (*p >= 'A' && *p <= 'Z')
@@ -192,6 +193,7 @@ but the Tcl message catalog format doesn't support plural handling\n")));
       {
        error (0, errno, _("error while opening \"%s\" for writing"),
               file_name);
+       freesa (frobbed_locale_name);
        return 1;
       }
 
@@ -203,6 +205,7 @@ but the Tcl message catalog format doesn't support plural handling\n")));
             file_name);
 
     fclose (output_file);
+    freesa (frobbed_locale_name);
   }
 
   return 0;
index b464f2d45de8bbff3dc1e391283beca95c197e39..b65300cce7ae9f2c4660658ed96409361ef7a82a 100644 (file)
@@ -44,6 +44,7 @@
 #include "basename.h"
 #include "xerror.h"
 #include "xalloc.h"
+#include "xallocsa.h"
 #include "strstr.h"
 #include "xerror.h"
 #include "exit.h"
@@ -1101,11 +1102,13 @@ flag_context_list_table_insert (flag_context_list_table_ty *table,
                                const char *name_start, const char *name_end,
                                int argnum, enum is_format value, bool pass)
 {
+  char *allocated_name = NULL;
+
   if (table == &flag_table_lisp)
     {
       /* Convert NAME to upper case.  */
       size_t name_len = name_end - name_start;
-      char *name = (char *) alloca (name_len);
+      char *name = allocated_name = (char *) xallocsa (name_len);
       size_t i;
 
       for (i = 0; i < name_len; i++)
@@ -1232,6 +1235,9 @@ flag_context_list_table_insert (flag_context_list_table_ty *table,
          }
       }
   }
+
+  if (allocated_name != NULL)
+    freesa (allocated_name);
 }
 
 
index 455c810c8a672f96355dad1990de40e3347290ea..0afc408c5e094e7cde5aef022511748e47bf7a30 100644 (file)
@@ -48,6 +48,7 @@ execute_java_class
 find_backup_file_name
 find_entry
 find_in_path
+freesa
 fstrcmp
 full_write
 fwriteerror
@@ -61,6 +62,7 @@ init_hash
 insert_entry
 iterate_table
 locale_charset
+mallocsa
 maybe_print_progname
 mbs_width_linebreaks
 mbsnwidth
@@ -100,6 +102,7 @@ xasprintf
 xcalloc
 xget_version
 xmalloc
+xmallocsa
 xrealloc
 xsetenv
 xstrdup