summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-09-11 17:26:21 -0700
committerRussell Belfer <rb@github.com>2012-09-11 17:26:21 -0700
commita13fb55afdbf9d74c3d4b6aa76476a005da49486 (patch)
tree9755770eed5893cce9d69e22f4f5a773d8c99220 /src/odb.c
parent47bfa0be6d509b60eda92705b57d3f7ba89c1c6b (diff)
downloadlibgit2-a13fb55afdbf9d74c3d4b6aa76476a005da49486.tar.gz
Add tests and improve param checks
Fixed some minor `git_repository_hashfile` issues: - Fixed incorrect doc (saying that repo could be NULL) - Added checking of object type value to acceptable ones - Added more tests for various parameter permutations
Diffstat (limited to 'src/odb.c')
-rw-r--r--src/odb.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/odb.c b/src/odb.c
index 0d3d809f7..943ffedaa 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -117,6 +117,11 @@ int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type)
git_hash_ctx *ctx;
ssize_t read_len;
+ if (!git_object_typeisloose(type)) {
+ giterr_set(GITERR_INVALID, "Invalid object type for hash");
+ return -1;
+ }
+
hdr_len = format_object_header(hdr, sizeof(hdr), size, type);
ctx = git_hash_new_ctx();