summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-02-09 18:25:46 +0000
committerGitHub <noreply@github.com>2018-02-09 18:25:46 +0000
commit05c24c44e67a09b88411aca5f12d31e907d1a35d (patch)
tree41b990f677473b22c288d37495f918ca28120d52
parent028a28066ff3aaf79767e9a5c5cc5ff6762cc4bc (diff)
parent178fda8ac9b7b2c2e56c5b2daf0ceff9df2d8f5d (diff)
downloadlibgit2-05c24c44e67a09b88411aca5f12d31e907d1a35d.tar.gz
Merge pull request #4527 from pks-t/pks/resource-leaks
Plug resource leaks
-rw-r--r--src/hash/hash_win32.c2
-rw-r--r--src/odb.c2
-rw-r--r--src/odb_loose.c4
3 files changed, 6 insertions, 2 deletions
diff --git a/src/hash/hash_win32.c b/src/hash/hash_win32.c
index 50c23e816..779802c4b 100644
--- a/src/hash/hash_win32.c
+++ b/src/hash/hash_win32.c
@@ -57,7 +57,7 @@ GIT_INLINE(int) hash_cng_prov_init(void)
if (hash_prov.prov.cng.open_algorithm_provider(&hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_TYPE, NULL, GIT_HASH_CNG_HASH_REUSABLE) < 0) {
FreeLibrary(hash_prov.prov.cng.dll);
- giterr_set(GITERR_OS "algorithm provider could not be initialized");
+ giterr_set(GITERR_OS, "algorithm provider could not be initialized");
return -1;
}
diff --git a/src/odb.c b/src/odb.c
index 802c721a8..07206c1ac 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 713288da2..470421e15 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -433,7 +433,8 @@ static int read_header_loose(git_rawobj *out, git_buf *loc)
}
done:
- p_close(fd);
+ if (fd >= 0)
+ p_close(fd);
return error;
}
@@ -1030,6 +1031,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);
}