summaryrefslogtreecommitdiff
path: root/lib/libedit/parse.c
diff options
context:
space:
mode:
authorPascal Stumpf <pascal@cvs.openbsd.org>2011-11-27 21:46:45 +0000
committerPascal Stumpf <pascal@cvs.openbsd.org>2011-11-27 21:46:45 +0000
commitde3168fa7d2cb83a7611478b2034e713ac22c0b6 (patch)
tree072c8e650f293d42fcd769f85b7160257b53dc97 /lib/libedit/parse.c
parent580a6f83c6877ccd2410dfe028c1cef205d1ca98 (diff)
Don't segfault when trying to bind to an invalid command. While here,
kill a C++-style comment. ok nicm@
Diffstat (limited to 'lib/libedit/parse.c')
-rw-r--r--lib/libedit/parse.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c
index 844b3b4b622..9a2d6808139 100644
--- a/lib/libedit/parse.c
+++ b/lib/libedit/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.10 2010/06/30 00:05:35 nicm Exp $ */
+/* $OpenBSD: parse.c,v 1.11 2011/11/27 21:46:44 pascal Exp $ */
/* $NetBSD: parse.c,v 1.23 2009/12/30 22:37:40 christos Exp $ */
/*-
@@ -271,9 +271,10 @@ protected int
parse_cmd(EditLine *el, const Char *cmd)
{
el_bindings_t *b;
+ int i;
- for (b = el->el_map.help; b->name != NULL; b++)
- if (Strcmp(b->name, cmd) == 0)
- return (b->func);
+ for (b = el->el_map.help, i = 0; i < el->el_map.nfunc; i++)
+ if (Strcmp(b[i].name, cmd) == 0)
+ return (b[i].func);
return (-1);
}