diff options
author | Andrew Stubbs <andrew.stubbs@st.com> | 2006-07-13 09:03:38 +0000 |
---|---|---|
committer | Andrew Stubbs <andrew.stubbs@st.com> | 2006-07-13 09:03:38 +0000 |
commit | 070bfa65c31d3d37f982c885b2d25073dd3cc99e (patch) | |
tree | a7ad1bd4c97cc27fbb2f0c7475fc4821875305ab /gdb/interps.c | |
parent | 083ea7ff97933d626103531d19f91bf4a4f6b78c (diff) | |
download | gdb-070bfa65c31d3d37f982c885b2d25073dd3cc99e.tar.gz |
2006-07-13 Denis PILAT <denis.pilat@st.com>
* interps.c (interpreter_completer): Allocate one more item to the
'matches' list and set them all to 0 with a xcalloc.
Diffstat (limited to 'gdb/interps.c')
-rw-r--r-- | gdb/interps.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/gdb/interps.c b/gdb/interps.c index a1b04926c01..f72f683f44a 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -424,10 +424,11 @@ interpreter_completer (char *text, char *word) struct interp *interp; /* We expect only a very limited number of interpreters, so just - allocate room for all of them. */ + allocate room for all of them plus one for the last that must be NULL + to correctly end the list. */ for (interp = interp_list; interp != NULL; interp = interp->next) ++alloced; - matches = (char **) xmalloc (alloced * sizeof (char *)); + matches = (char **) xcalloc (alloced + 1, sizeof (char *)); num_matches = 0; textlen = strlen (text); @@ -460,12 +461,6 @@ interpreter_completer (char *text, char *word) xfree (matches); matches = NULL; } - else if (num_matches < alloced) - { - matches = (char **) xrealloc ((char *) matches, ((num_matches + 1) - * sizeof (char *))); - matches[num_matches] = NULL; - } return matches; } |