Merge pull request #4527 from pks-t/pks/resource-leaks Plug resource leaks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/src/hash/hash_win32.c b/src/hash/hash_win32.c
index 50c23e8..779802c 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 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..470421e 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);
}