Fix memleak of cmdline in app/test/test.c
---
 app/test/commands.c | 2 +-
 app/test/test.c     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/test/commands.c b/app/test/commands.c
index 9cb9606..5dfa599 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -439,7 +439,7 @@ int commands_init(void)
                commands_len += strlen(t->command) + 1;
        }

-       commands = malloc(commands_len);
+       commands = malloc(commands_len + 1); /* one more byte for \0 */
        if (!commands)
                return -1;

diff --git a/app/test/test.c b/app/test/test.c
index f35b304..108a347 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -150,6 +150,7 @@ main(int argc, char **argv)
        }
        cmdline_interact(cl);
        cmdline_stdin_exit(cl);
+        cmdline_free(cl);
 #endif

        return 0;
-- 
1.9.1

Reply via email to