diff options
author | Russell Belfer <rb@github.com> | 2013-01-08 17:11:11 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-01-08 17:11:11 -0800 |
commit | de590550172c68bf374f9d12636b06295c5fe048 (patch) | |
tree | 3bf0c7ca4b554784de72063b25933775308fb512 /src/fileops.c | |
parent | f7e4a7c2d5e314fe50fee851263e4ed6cfaa49ae (diff) | |
download | libgit2-de590550172c68bf374f9d12636b06295c5fe048.tar.gz |
Resolve crash with diff against empty file
It is not legal inside our `p_mmap` function to mmap a zero length
file. This adds a test that exercises that case inside diff and
fixes the code path where we would try to do that.
The fix turns out not to be a lot of code since our default file
content is already initialized to "" which works in this case.
Fixes #1210
Diffstat (limited to 'src/fileops.c')
-rw-r--r-- | src/fileops.c | 2 |
1 files changed, 1 insertions, 1 deletions
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); |