Closed tonymarklove closed 6 years ago
Following up on my issue from #50, utf8ncpy doesn't (now) correctly stop at n bytes unless it hits the null-terminator in src. The following code demonstrates the problem:
utf8ncpy
n
src
#include "utf8.h" int main(int argc, char* argv[]) { char buffer[10]; utf8ncpy(buffer, "foo", 2); }
Running this program results in a segmentation fault for me, due to n looping round past 0.
Changing the 2 to 3 works, because the null-terminator is hit at the end of the string "foo".
2
3
"foo"
Following up on my issue from #50,
utf8ncpy
doesn't (now) correctly stop atn
bytes unless it hits the null-terminator insrc
. The following code demonstrates the problem:Running this program results in a segmentation fault for me, due to
n
looping round past 0.Changing the
2
to3
works, because the null-terminator is hit at the end of the string"foo"
.