diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-05-30 15:41:17 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-05-30 15:41:45 +0200 |
| commit | 3939baf87d2b8776b47eff2c058fceaa351d9550 (patch) | |
| tree | 54fd2020480b0e69db0545eacaf645e4e1ee13ca /alf | |
| parent | 21daf33e67796a2422aca2bbbf4c61a5851738b8 (diff) | |
fix overflow possibility in ALF_Alloc
Diffstat (limited to 'alf')
| -rw-r--r-- | alf/alf.cpp | 8 |
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 |
