OSDN Git Service

(used_arg): When call xmalloc for mswitches, pass 1 if
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Oct 1996 18:18:44 +0000 (18:18 +0000)
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Oct 1996 18:18:44 +0000 (18:18 +0000)
n_switches is zero.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@12885 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/gcc.c

index 0b84a83..10653dc 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);