From 3939baf87d2b8776b47eff2c058fceaa351d9550 Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Sat, 30 May 2020 15:41:17 +0200 Subject: fix overflow possibility in ALF_Alloc --- alf/alf.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/alf/alf.cpp b/alf/alf.cpp index 641baec..32d5cc7 100644 --- a/alf/alf.cpp +++ b/alf/alf.cpp @@ -80,14 +80,18 @@ ALF_UnInitialize(void) void * ALF_Alloc(SIZE_T nmemb, SIZE_T size) { - // FIXME! potential overflow + if (size && nmemb > (SIZE_T)-1 / size) + RaiseException(STATUS_NO_MEMORY, 0, 0, NULL); + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY|HEAP_GENERATE_EXCEPTIONS, nmemb * size); } void * ALF_ReAlloc(void *ptr, SIZE_T nmemb, SIZE_T size) { - // FIXME! potential overflow + if (size && nmemb > (SIZE_T)-1 / size) + RaiseException(STATUS_NO_MEMORY, 0, 0, NULL); + if (ptr) return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY|HEAP_GENERATE_EXCEPTIONS, ptr, nmemb * size); else -- cgit v1.2.3