Merge pull request #4008 from pks-t/pks/sortedcache-fd-leak
sortedcache: plug leaked file descriptor
diff --git a/src/patch_parse.c b/src/patch_parse.c
index 7a4fe9f..f527594 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -1014,8 +1014,10 @@
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);
}
diff --git a/src/sortedcache.c b/src/sortedcache.c
index ed4199b..5bd989a 100644
--- a/src/sortedcache.c
+++ b/src/sortedcache.c
@@ -216,6 +216,7 @@
if (p_fstat(fd, &st) < 0) {
giterr_set(GITERR_OS, "failed to stat file");
error = -1;
+ (void)p_close(fd);
goto unlock;
}