Commits

Jim Meyering  committed dc4cd76

plug a few coverity-spotted leaks

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

  • Participants
  • Parent commits 28eb1af

Comments (0)

Files changed (4)

File builtin/cat-file.c

 	if (type <= 0) {
 		printf("%s missing\n", obj_name);
 		fflush(stdout);
+		if (print_contents == BATCH)
+			free(contents);
 		return 0;
 	}
 

File builtin/diff.c

 		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;
 }
 

File builtin/update-index.c

 	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))

File remote-curl.c

 
 		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)