6 May 2012 08:55
[PATCH 3/4] help.c: plug a leak when help.autocorrect is set
Tay Ray Chuan <rctay89 <at> gmail.com>
2012-05-06 06:55:29 GMT
2012-05-06 06:55:29 GMT
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 <rctay89 <at> gmail.com>
---
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
<at> <at> -360,8 +360,7 <at> <at> 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
RSS Feed