(used_arg): When call xmalloc for mswitches, pass 1 if
authorJim Wilson <wilson@gcc.gnu.org>
Tue, 1 Oct 1996 18:18:44 +0000 (11:18 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Tue, 1 Oct 1996 18:18:44 +0000 (11:18 -0700)
n_switches is zero.

From-SVN: r12885

gcc/gcc.c

index 0b84a83d50c9309dce6afdbc79514eb23884e71b..10653dc0ccc18dd24a6cdabeeba048e7b1558ec8 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4982,8 +4982,13 @@ used_arg (p, len)
            break;
        }
 
-      /* Now build a list of the replacement string for switches that we care about */
-      mswitches = (struct mswitchstr *) xmalloc ((sizeof (struct mswitchstr)) * n_switches);
+      /* Now build a list of the replacement string for switches that we care
+        about.  Make sure we allocate at least one entry.  This prevents
+        xmalloc from calling fatal, and prevents us from re-executing this
+        block of code.  */
+      mswitches
+       = (struct mswitchstr *) xmalloc ((sizeof (struct mswitchstr))
+                                        * (n_switches ? n_switches : 1));
       for (i = 0; i < n_switches; i++)
        {
          int xlen = strlen (switches[i].part1);