Merge branch 'nd/strbuf-utf8-replace'
* nd/strbuf-utf8-replace: utf8.c: fix strbuf_utf8_replace() consuming data beyond input string
This commit is contained in:
commit
1764e8124e
@ -431,6 +431,13 @@ EOF
|
|||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'strbuf_utf8_replace() not producing NUL' '
|
||||||
|
git log --color --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)%C(auto)%d" |
|
||||||
|
test_decode_color |
|
||||||
|
nul_to_q >actual &&
|
||||||
|
! grep Q actual
|
||||||
|
'
|
||||||
|
|
||||||
# get new digests (with no abbreviations)
|
# get new digests (with no abbreviations)
|
||||||
head1=$(git rev-parse --verify HEAD~0) &&
|
head1=$(git rev-parse --verify HEAD~0) &&
|
||||||
head2=$(git rev-parse --verify HEAD~1) &&
|
head2=$(git rev-parse --verify HEAD~1) &&
|
||||||
|
3
utf8.c
3
utf8.c
@ -382,6 +382,9 @@ void strbuf_utf8_replace(struct strbuf *sb_src, int pos, int width,
|
|||||||
dst += n;
|
dst += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src >= end)
|
||||||
|
break;
|
||||||
|
|
||||||
old = src;
|
old = src;
|
||||||
n = utf8_width((const char**)&src, NULL);
|
n = utf8_width((const char**)&src, NULL);
|
||||||
if (!src) /* broken utf-8, do nothing */
|
if (!src) /* broken utf-8, do nothing */
|
||||||
|
Loading…
Reference in New Issue
Block a user