Commit a43bcd2c5392586f987d0c3c6247e75699ba135d

Patrick Steinhardt 2018-02-09T17:31:50

odb: fix memory leaks due to not freeing hash context

diff --git a/src/odb.c b/src/odb.c
index 802c721..07206c1 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1373,6 +1373,8 @@ int git_odb_open_wstream(
 	(*stream)->received_bytes = 0;
 
 done:
+	if (error)
+		git__free(ctx);
 	return error;
 }
 
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 713288d..7032b8a 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -1030,6 +1030,7 @@ done:
 		git_futils_mmap_free(&stream->map);
 		git_zstream_free(&stream->zstream);
 		git_hash_ctx_cleanup(hash_ctx);
+		git__free(hash_ctx);
 		git__free(stream);
 	}