+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-06-20 Joel Brobecker <brobecker@adacore.com>
* version.in: Set version to 6.5.0.<date>-cvs now that release
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);
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;
}