From 24b2182c5a77945bedbc5de0f1b4a9b6f5d27284 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Nov 2016 12:53:53 +0100 Subject: [PATCH 1/2] sortedcache: plug leaked file descriptor --- src/sortedcache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sortedcache.c b/src/sortedcache.c index ed4199b71..5bd989a9f 100644 --- a/src/sortedcache.c +++ b/src/sortedcache.c @@ -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; } From 613381fc1461514fdbb1518799bcee0345fdece6 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Nov 2016 13:33:05 +0100 Subject: [PATCH 2/2] patch_parse: fix memory leak --- src/patch_parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/patch_parse.c b/src/patch_parse.c index 7a4fe9f1a..f5275947d 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -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); }