X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/866f8763175ff60e4fa455b92b5eb660a12fe6c7..0d4552ce43ff8bf2e8666a9c5c44c3590eb117a8:/OSX/libsecurity_utilities/lib/alloc.cpp diff --git a/OSX/libsecurity_utilities/lib/alloc.cpp b/OSX/libsecurity_utilities/lib/alloc.cpp index 313d187e..5d297087 100644 --- a/OSX/libsecurity_utilities/lib/alloc.cpp +++ b/OSX/libsecurity_utilities/lib/alloc.cpp @@ -137,8 +137,12 @@ void *SensitiveAllocator::realloc(void *addr, size_t newSize) throw(std::bad_all // void *CssmHeap::operator new (size_t size, Allocator *alloc) throw(std::bad_alloc) { - if (alloc == NULL) + if (size > SIZE_T_MAX / 2) { + throw std::bad_alloc(); + } + if (alloc == NULL) { alloc = &Allocator::standard(); + } size = alignUp(size, alignof_template()); size_t totalSize = size + sizeof(Allocator *); void *addr = alloc->malloc(totalSize);