Skip to content

Commit

Permalink
Fix sizeof usage in get_permutations
Browse files Browse the repository at this point in the history
Currently it gets the size of an otherwise unrelated, unused variable
instead of the expected struct size.

Signed-off-by: Matthew Daley <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Matthew Daley authored and gitster committed Dec 13, 2012
1 parent 75940a0 commit bdd478d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builtin/pack-redundant.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,14 @@ static void pll_free(struct pll *l)
*/
static struct pll * get_permutations(struct pack_list *list, int n)
{
struct pll *subset, *ret = NULL, *new_pll = NULL, *pll;
struct pll *subset, *ret = NULL, *new_pll = NULL;

if (list == NULL || pack_list_size(list) < n || n == 0)
return NULL;

if (n == 1) {
while (list) {
new_pll = xmalloc(sizeof(pll));
new_pll = xmalloc(sizeof(*new_pll));
new_pll->pl = NULL;
pack_list_insert(&new_pll->pl, list);
new_pll->next = ret;
Expand All @@ -321,7 +321,7 @@ static struct pll * get_permutations(struct pack_list *list, int n)
while (list->next) {
subset = get_permutations(list->next, n - 1);
while (subset) {
new_pll = xmalloc(sizeof(pll));
new_pll = xmalloc(sizeof(*new_pll));
new_pll->pl = subset->pl;
pack_list_insert(&new_pll->pl, list);
new_pll->next = ret;
Expand Down

0 comments on commit bdd478d

Please sign in to comment.