]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2006-07-13 Denis PILAT <denis.pilat@st.com>
authorAndrew Stubbs <andrew.stubbs@st.com>
Mon, 17 Jul 2006 11:40:42 +0000 (11:40 +0000)
committerAndrew Stubbs <andrew.stubbs@st.com>
Mon, 17 Jul 2006 11:40:42 +0000 (11:40 +0000)
* interps.c (interpreter_completer): Allocate one more item to the
'matches' list and set them all to 0 with a xcalloc.

gdb/ChangeLog
gdb/interps.c

index 1ffd75109bafc43ea97620842fa7daa6f551513a..0a59c338a0a7bc8aafa6377550a2b45d5ccc3035 100644 (file)
@@ -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-06-20  Joel Brobecker  <brobecker@adacore.com>
 
        * version.in: Set version to 6.5.0.<date>-cvs now that release
index a1b04926c01e5159f1902b44177b4606adb8e277..f72f683f44a87eebfcf2d5c99a5dd2f622f81cb7 100644 (file)
@@ -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;
 }