From 139d3d5a3b907428faa44e47951a4c420e429d06 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 12 Jan 2010 19:40:50 +0000 Subject: [PATCH] - 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) --- lib/libedit/eln.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c index 932cafaa6eea..9accd3e66097 100644 --- a/lib/libedit/eln.c +++ b/lib/libedit/eln.c @@ -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; }