summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/diff_output.c3
-rw-r--r--src/fileops.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/diff_output.c b/src/diff_output.c
index e80cfaa84..f98665dfb 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -376,6 +376,9 @@ static int get_workdir_content(
goto close_and_cleanup;
if (error == 0) { /* note: git_filters_load returns filter count */
+ if (!file->size)
+ goto close_and_cleanup;
+
error = git_futils_mmap_ro(map, fd, 0, (size_t)file->size);
file->flags |= GIT_DIFF_FILE_UNMAP_DATA;
} else {
diff --git a/src/fileops.c b/src/fileops.c
index f2b6b0174..23cb07eb6 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -121,7 +121,7 @@ mode_t git_futils_canonical_mode(mode_t raw_mode)
int git_futils_readbuffer_fd(git_buf *buf, git_file fd, size_t len)
{
- ssize_t read_size;
+ ssize_t read_size = 0;
git_buf_clear(buf);