Commit 0cd162be by Carlos Martín Nieto Committed by GitHub

Merge pull request #4008 from pks-t/pks/sortedcache-fd-leak

sortedcache: plug leaked file descriptor
parents 1db3035d 613381fc
...@@ -1014,8 +1014,10 @@ git_patch_parse_ctx *git_patch_parse_ctx_init( ...@@ -1014,8 +1014,10 @@ git_patch_parse_ctx *git_patch_parse_ctx_init(
return NULL; return NULL;
if (content_len) { if (content_len) {
if ((ctx->content = git__malloc(content_len)) == NULL) if ((ctx->content = git__malloc(content_len)) == NULL) {
git__free(ctx);
return NULL; return NULL;
}
memcpy((char *)ctx->content, content, content_len); memcpy((char *)ctx->content, content, content_len);
} }
......
...@@ -216,6 +216,7 @@ int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf) ...@@ -216,6 +216,7 @@ int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf)
if (p_fstat(fd, &st) < 0) { if (p_fstat(fd, &st) < 0) {
giterr_set(GITERR_OS, "failed to stat file"); giterr_set(GITERR_OS, "failed to stat file");
error = -1; error = -1;
(void)p_close(fd);
goto unlock; goto unlock;
} }
......
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