Commit 581a4d3942ae5a66933632530fccd65f93ac5e4b

Edward Thomson 2016-07-14T23:32:35

apply: safety check files that dont end with eol

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/apply.c b/src/apply.c
index e982ab6..40ba647 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);