- call the mapping function directly instead of el_wset().

- save the strings passed to the mapping function so that they don't get
  re-used. This leaks. To fix it properly we could either pass a flag to
  free particular entries before re-using, or allocate all of them.
  Allocating all of them wastes memory, allocating some of them makes
  the code more complex.
This fixes compatibility binding (shell tab completion for example)
This commit is contained in:
christos 2010-01-12 19:40:50 +00:00
parent c9043bbf6e
commit 139d3d5a3b
1 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: eln.c,v 1.3 2009/12/31 15:58:26 christos Exp $ */
/* $NetBSD: eln.c,v 1.4 2010/01/12 19:40:50 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
__RCSID("$NetBSD: eln.c,v 1.3 2009/12/31 15:58:26 christos Exp $");
__RCSID("$NetBSD: eln.c,v 1.4 2010/01/12 19:40:50 christos Exp $");
#endif /* not lint && not SCCSID */
#include "histedit.h"
@ -191,7 +191,9 @@ el_set(EditLine *el, int op, ...)
ret = -1;
goto out;
}
ret = el_wset(el, op, wargv[0], wargv[1], func);
// XXX: The two strdup's leak
ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]),
func);
ct_free_argv(wargv);
break;
}