help.c::exclude_cmds(): plug a leak

Command name removed from the list of commands via the exclusion
were overwritten and lost without being freed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2012-07-25 11:01:12 -07:00
parent 4a15758f2e
commit 6a17f583f4

7
help.c
View File

@ -64,9 +64,10 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name); cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);
if (cmp < 0) if (cmp < 0)
cmds->names[cj++] = cmds->names[ci++]; cmds->names[cj++] = cmds->names[ci++];
else if (cmp == 0) else if (cmp == 0) {
ci++, ei++; ei++;
else if (cmp > 0) free(cmds->names[ci++]);
} else if (cmp > 0)
ei++; ei++;
} }