summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-07-14 23:32:35 -0400
committerEdward Thomson <ethomson@github.com>2016-07-24 15:49:19 -0400
commit581a4d3942ae5a66933632530fccd65f93ac5e4b (patch)
tree17e43940815712dfb1b556a12daf9edd0b368e3d
parentc065f6a1d2b9c7c64646a6c0e65abbb3ca0dc4b1 (diff)
downloadlibgit2-581a4d3942ae5a66933632530fccd65f93ac5e4b.tar.gz
apply: safety check files that dont end with eol
-rw-r--r--src/apply.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/apply.c b/src/apply.c
index e982ab682..40ba647f4 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -53,7 +53,10 @@ static int patch_image_init_fromstr(
for (start = in; start < in + in_len; start = end) {
end = memchr(start, '\n', in_len);
- if (end < in + in_len)
+ if (end == NULL)
+ end = in + in_len;
+
+ else if (end < in + in_len)
end++;
line = git_pool_mallocz(&out->pool, 1);