summaryrefslogtreecommitdiff
path: root/lib/libedit
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
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')
-rw-r--r--lib/libedit/eln.c4
-rw-r--r--lib/libedit/parse.c9
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c
index 50c79e83207..eb14581d92b 100644
--- a/lib/libedit/eln.c
+++ b/lib/libedit/eln.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eln.c,v 1.2 2011/07/07 05:40:42 okan Exp $ */
+/* $OpenBSD: eln.c,v 1.3 2011/11/27 21:46:44 pascal Exp $ */
/* $NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $ */
/*-
@@ -205,7 +205,7 @@ el_set(EditLine *el, int op, ...)
ret = -1;
goto out;
}
- // XXX: The two strdup's leak
+ /* XXX: The two strdup's leak */
ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]),
func);
ct_free_argv(wargv);
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);
}