Skip to content

Commit bdd478d

Browse files
Matthew Daleygitster
authored andcommitted
Fix sizeof usage in get_permutations
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]>
1 parent 75940a0 commit bdd478d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/pack-redundant.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ static void pll_free(struct pll *l)
301301
*/
302302
static struct pll * get_permutations(struct pack_list *list, int n)
303303
{
304-
struct pll *subset, *ret = NULL, *new_pll = NULL, *pll;
304+
struct pll *subset, *ret = NULL, *new_pll = NULL;
305305

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

309309
if (n == 1) {
310310
while (list) {
311-
new_pll = xmalloc(sizeof(pll));
311+
new_pll = xmalloc(sizeof(*new_pll));
312312
new_pll->pl = NULL;
313313
pack_list_insert(&new_pll->pl, list);
314314
new_pll->next = ret;
@@ -321,7 +321,7 @@ static struct pll * get_permutations(struct pack_list *list, int n)
321321
while (list->next) {
322322
subset = get_permutations(list->next, n - 1);
323323
while (subset) {
324-
new_pll = xmalloc(sizeof(pll));
324+
new_pll = xmalloc(sizeof(*new_pll));
325325
new_pll->pl = subset->pl;
326326
pack_list_insert(&new_pll->pl, list);
327327
new_pll->next = ret;

0 commit comments

Comments
 (0)