Skip to content

Commit

Permalink
plug a few coverity-spotted leaks
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jim Meyering authored and Junio C Hamano committed Jun 20, 2011
1 parent 28eb1af commit dc4cd76
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions builtin/cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ static int batch_one_object(const char *obj_name, int print_contents)
if (type <= 0) {
printf("%s missing\n", obj_name);
fflush(stdout);
if (print_contents == BATCH)
free(contents);
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions builtin/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ static int builtin_diff_combined(struct rev_info *revs,
hashcpy((unsigned char *)(parent + i), ent[i].item->sha1);
diff_tree_combined(parent[0], parent + 1, ents - 1,
revs->dense_combined_merges, revs);
free(parent);
return 0;
}

Expand Down
4 changes: 3 additions & 1 deletion builtin/update-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ static int add_one_path(struct cache_entry *old, const char *path, int len, stru
ce->ce_mode = ce_mode_from_stat(old, st->st_mode);

if (index_path(ce->sha1, path, st,
info_only ? 0 : HASH_WRITE_OBJECT))
info_only ? 0 : HASH_WRITE_OBJECT)) {
free(ce);
return -1;
}
option = allow_add ? ADD_CACHE_OK_TO_ADD : 0;
option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;
if (add_cache_entry(ce, option))
Expand Down
10 changes: 6 additions & 4 deletions remote-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,19 +811,21 @@ static void parse_push(struct strbuf *buf)

strbuf_reset(buf);
if (strbuf_getline(buf, stdin, '\n') == EOF)
return;
goto free_specs;
if (!*buf->buf)
break;
} while (1);

if (push(nr_spec, specs))
exit(128); /* error already reported */
for (i = 0; i < nr_spec; i++)
free(specs[i]);
free(specs);

printf("\n");
fflush(stdout);

free_specs:
for (i = 0; i < nr_spec; i++)
free(specs[i]);
free(specs);
}

int main(int argc, const char **argv)
Expand Down

0 comments on commit dc4cd76

Please sign in to comment.