From: Tay Ray Chuan Date: Sun, 06 May 2012 06:55:29 GMT Subject: [PATCH 3/4] help.c: plug a leak when help.autocorrect is set Message-ID: <1336287330-7215-4-git-send-email-rctay89@gmail.com> In-Reply-To: <1336287330-7215-3-git-send-email-rctay89@gmail.com> In an attempt to retain the memory to the string name in main_cmds, we unfortunately leaked the struct cmdname that held it. Fix this by creating a copy of the name. Signed-off-by: Tay Ray Chuan --- help.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/help.c b/help.c index 705f152..f296d95 100644 --- a/help.c +++ b/help.c @@ -360,8 +360,7 @@ const char *help_unknown_cmd(const char *cmd) ; /* still counting */ } if (autocorrect && n == 1 && SIMILAR_ENOUGH(best_similarity)) { - const char *assumed = main_cmds.names[0]->name; - main_cmds.names[0] = NULL; + const char *assumed = xstrdup(main_cmds.names[0]->name); clean_cmdnames(&main_cmds); fprintf_ln(stderr, _("WARNING: You called a Git command named '%s', " -- 1.7.10.1.611.g8a79d96