Skip to content

Commit

Permalink
help.c::exclude_cmds(): plug a leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jul 25, 2012
1 parent 4a15758 commit 6a17f58
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions help.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);
if (cmp < 0)
cmds->names[cj++] = cmds->names[ci++];
else if (cmp == 0)
ci++, ei++;
else if (cmp > 0)
else if (cmp == 0) {
ei++;
free(cmds->names[ci++]);
} else if (cmp > 0)
ei++;
}

Expand Down

0 comments on commit 6a17f58

Please sign in to comment.