提交 62f4ab13 编写于 作者: S Shuai Yuan 提交者: GitHub

Give advice for Alloc function users (#1575)

* BugFix: add input parameters checking for Alloc

* Give advice for Alloc function users

* Give advice for Alloc function users
上级 7fc088b4
......@@ -67,6 +67,8 @@ void Copy(void *dst, const void *src, size_t num) {
}
void *Alloc(size_t size) {
// segmentation fault if size_t overflow on 32-bit platforms
// user should check before calling this function
size_t offset = sizeof(void *) + MALLOC_ALIGN - 1;
char *p = static_cast<char *>(malloc(offset + size));
if (!p) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册