summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/odb.c5
-rw-r--r--src/repository.c7
2 files changed, 11 insertions, 1 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();
diff --git a/src/repository.c b/src/repository.c
index ab139a723..bcc6b1503 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1388,7 +1388,12 @@ int git_repository_hashfile(
git_off_t len;
git_buf full_path = GIT_BUF_INIT;
- assert(out && path); /* repo and as_path can be NULL */
+ assert(out && path && repo); /* as_path can be NULL */
+
+ /* At some point, it would be nice if repo could be NULL to just
+ * apply filter rules defined in system and global files, but for
+ * now that is not possible because git_filters_load() needs it.
+ */
error = git_path_join_unrooted(
&full_path, path, repo ? git_repository_workdir(repo) : NULL, NULL);