diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2020-11-30 16:50:51 +0100 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2020-11-30 16:55:40 +0100 |
commit | 6df43392d8703df6e92b7ae6e96373e6c3fc5083 (patch) | |
tree | 24694e9cbb47dcc06281f7da2b55b69f98380a74 /vtysh | |
parent | vtysh: fix memory leak (diff) | |
download | frr-6df43392d8703df6e92b7ae6e96373e6c3fc5083.tar.xz frr-6df43392d8703df6e92b7ae6e96373e6c3fc5083.zip |
vtysh: fix incorrect memory statistics
As code comment states, 1 count of MTYPE_COMPLETION is leaked for each
autocompleted token. Let's manually decrement the counter before passing
the pointer to readline.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/vtysh.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index ace413955..ef0dfccba 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1144,12 +1144,10 @@ static char *command_generator(const char *text, int state) cmd_free_strvec(vline); } - if (matched && matched[index]) - /* - * this is free()'d by readline, but we leak 1 count of - * MTYPE_COMPLETION - */ + if (matched && matched[index]) { + XCOUNTFREE(MTYPE_COMPLETION, matched[index]); return matched[index++]; + } XFREE(MTYPE_TMP, matched); |