提交 d9bdfd16 编写于 作者: Q Quentin Rameau 提交者: Rich Felker

fix memccpy to not access buffer past given size

memccpy would return a pointer over the given size when c is not
found in the source buffer and n reaches 0.
上级 39ef612a
......@@ -29,6 +29,6 @@ void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n)
#endif
for (; n && (*d=*s)!=c; n--, s++, d++);
tail:
if (*s==c) return d+1;
if (n && *s==c) return d+1;
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册