summaryrefslogtreecommitdiff
path: root/rerere.c
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2013-04-01 23:36:36 +0200
committerJunio C Hamano <gitster@pobox.com>2013-04-02 13:00:41 -0700
commit53d8afafbbf455d24b0a94e4114709a4d495d460 (patch)
tree72e962bc7cc59eef2bd01fc4f422dca3b8462eab /rerere.c
parent15999998fbda60552742275570947431b57108ae (diff)
downloadgit-53d8afafbbf455d24b0a94e4114709a4d495d460.tar.gz
rerere forget: grok files containing NUL
Using 'git rerere forget .' after a merge that involved binary files runs into an infinite loop if the binary file contains a zero byte. Replace a strchrnul by memchr because the former does not make progress as soon as the NUL is encountered. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rerere.c')
-rw-r--r--rerere.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/rerere.c b/rerere.c
index a6a5cd57be..4d940cd375 100644
--- a/rerere.c
+++ b/rerere.c
@@ -284,8 +284,10 @@ static int rerere_mem_getline(struct strbuf *sb, struct rerere_io *io_)
strbuf_release(sb);
if (!io->input.len)
return -1;
- ep = strchrnul(io->input.buf, '\n');
- if (*ep == '\n')
+ ep = memchr(io->input.buf, '\n', io->input.len);
+ if (!ep)
+ ep = io->input.buf + io->input.len;
+ else if (*ep == '\n')
ep++;
len = ep - io->input.buf;
strbuf_add(sb, io->input.buf, len);