diff options
author | wilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4> | 1996-10-01 18:18:44 +0000 |
---|---|---|
committer | wilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4> | 1996-10-01 18:18:44 +0000 |
commit | 0a4dc6a9280e0ecf2825693fa97fc38a473c4a2d (patch) | |
tree | 23cf3bc55c9b0a5303b9279a7d7a045f090bd3f0 /gcc/gcc.c | |
parent | 2d7f129bd8c91bac9d70642249eb24e2c18e797e (diff) | |
download | gcc-0a4dc6a9280e0ecf2825693fa97fc38a473c4a2d.tar.gz |
(used_arg): When call xmalloc for mswitches, pass 1 if
n_switches is zero.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@12885 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c index 0b84a83d50c..10653dc0ccc 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); |