tsan: check for overflow in malloc()

llvm-svn: 157048
This commit is contained in:
Dmitry Vyukov 2012-05-18 09:41:52 +00:00
parent bea47a5029
commit f64046cb3d
1 changed files with 2 additions and 0 deletions

View File

@ -30,6 +30,8 @@ static void SignalUnsafeCall(ThreadState *thr, uptr pc) {
void *user_alloc(ThreadState *thr, uptr pc, uptr sz) {
CHECK_GT(thr->in_rtl, 0);
if (sz + sizeof(MBlock) < sz)
return 0;
MBlock *b = (MBlock*)Alloc(sz + sizeof(MBlock));
b->size = sz;
void *p = b + 1;