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

sortedcache: plug leaked file descriptor
This commit is contained in:
Carlos Martín Nieto 2016-11-15 16:28:10 +01:00 committed by GitHub
commit 0cd162be88
2 changed files with 4 additions and 1 deletions

View File

@ -1014,8 +1014,10 @@ git_patch_parse_ctx *git_patch_parse_ctx_init(
return NULL;
if (content_len) {
if ((ctx->content = git__malloc(content_len)) == NULL)
if ((ctx->content = git__malloc(content_len)) == NULL) {
git__free(ctx);
return NULL;
}
memcpy((char *)ctx->content, content, content_len);
}

View File

@ -216,6 +216,7 @@ int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf)
if (p_fstat(fd, &st) < 0) {
giterr_set(GITERR_OS, "failed to stat file");
error = -1;
(void)p_close(fd);
goto unlock;
}