Commit bc040875 by Edward Thomson

index_pack: close fd on error

If we're reading an on-disk packfile, ensure that we close the file
descriptor on error.
parent a360b013
...@@ -97,9 +97,6 @@ int cmd_index_pack(int argc, char **argv) ...@@ -97,9 +97,6 @@ int cmd_index_pack(int argc, char **argv)
} }
} }
if (!read_stdin)
p_close(fd);
if (git_indexer_commit(idx, &stats) < 0) { if (git_indexer_commit(idx, &stats) < 0) {
ret = cli_error_git(); ret = cli_error_git();
goto done; goto done;
...@@ -108,6 +105,9 @@ int cmd_index_pack(int argc, char **argv) ...@@ -108,6 +105,9 @@ int cmd_index_pack(int argc, char **argv)
cli_progress_finish(&progress); cli_progress_finish(&progress);
done: done:
if (!read_stdin && fd >= 0)
p_close(fd);
cli_progress_dispose(&progress); cli_progress_dispose(&progress);
git_indexer_free(idx); git_indexer_free(idx);
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment