mirror of
https://github.com/git-for-windows/git.git
synced 2026-03-17 22:19:19 -05:00
fixup! built-in add -p: implement the hunk splitting feature
Let's be a bit more defensive in the code that finds the next line: if we are already at the end of the buffer, we definitely do _not_ want to return an offset that is outside the buffer! Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -562,8 +562,13 @@ mismatched_output:
|
||||
|
||||
static size_t find_next_line(struct strbuf *sb, size_t offset)
|
||||
{
|
||||
char *eol = memchr(sb->buf + offset, '\n', sb->len - offset);
|
||||
char *eol;
|
||||
|
||||
if (offset >= sb->len)
|
||||
BUG("looking for next line beyond buffer (%d >= %d)\n%s",
|
||||
(int)offset, (int)sb->len, sb->buf);
|
||||
|
||||
eol = memchr(sb->buf + offset, '\n', sb->len - offset);
|
||||
if (!eol)
|
||||
return sb->len;
|
||||
return eol - sb->buf + 1;
|
||||
|
||||
Reference in New Issue
Block a user