aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1996-10-01 11:18:44 -0700
committerJim Wilson <wilson@gcc.gnu.org>1996-10-01 11:18:44 -0700
commit71591a1d691fd6529e7a889166646249bc5187c3 (patch)
tree23cf3bc55c9b0a5303b9279a7d7a045f090bd3f0 /gcc
parentafad3d2c2608d4905fdb7446810ee826fb142501 (diff)
downloadgcc-71591a1d691fd6529e7a889166646249bc5187c3.zip
gcc-71591a1d691fd6529e7a889166646249bc5187c3.tar.gz
gcc-71591a1d691fd6529e7a889166646249bc5187c3.tar.bz2
(used_arg): When call xmalloc for mswitches, pass 1 if
n_switches is zero. From-SVN: r12885
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gcc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 0b84a83..10653dc 100644
--- 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);