summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alf/alf.cpp8
1 files 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