aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stubbs <andrew.stubbs@st.com>2006-07-13 09:03:38 +0000
committerAndrew Stubbs <andrew.stubbs@st.com>2006-07-13 09:03:38 +0000
commit9af2a05463af610d6e166ba4e2831f8fbca7cfb0 (patch)
treeb4135c8c56203af3d46e11eaa72cfc76d43223c1
parent24ca47234f4e886d1dff4607150549c66ead0e87 (diff)
downloadfsf-binutils-gdb-9af2a05463af610d6e166ba4e2831f8fbca7cfb0.zip
fsf-binutils-gdb-9af2a05463af610d6e166ba4e2831f8fbca7cfb0.tar.gz
fsf-binutils-gdb-9af2a05463af610d6e166ba4e2831f8fbca7cfb0.tar.bz2
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.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/interps.c11
2 files changed, 8 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c954e95..5424058 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
2006-07-13 Nick Roberts <nickrob@snap.net.nz>
* annotate.c (annotate_frame_begin): Re-instate frame-begin
diff --git a/gdb/interps.c b/gdb/interps.c
index a1b0492..f72f683 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;
}