Module: wine Branch: master Commit: e0ea2318921b0c91897818f12590e6454869f8bd URL: https://gitlab.winehq.org/wine/wine/-/commit/e0ea2318921b0c91897818f12590e64...
Author: Rémi Bernon rbernon@codeweavers.com Date: Sat Nov 12 14:28:00 2022 +0100
kernelbase: Validate pointers before calling heap functions.
---
dlls/kernelbase/memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c index 2a503587e93..4c462c1633b 100644 --- a/dlls/kernelbase/memory.c +++ b/dlls/kernelbase/memory.c @@ -903,7 +903,8 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalFree( HLOCAL handle ) TRACE_(globalmem)( "handle %p\n", handle );
RtlLockHeap( heap ); - if ((ptr = unsafe_ptr_from_HLOCAL( handle ))) + if ((ptr = unsafe_ptr_from_HLOCAL( handle )) && + HeapValidate( heap, HEAP_NO_SERIALIZE, ptr )) { if (HeapFree( heap, HEAP_NO_SERIALIZE, ptr )) ret = 0; } @@ -985,7 +986,8 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL handle, SIZE_T size, UINT f if (flags & LMEM_ZEROINIT) heap_flags |= HEAP_ZERO_MEMORY;
RtlLockHeap( heap ); - if ((ptr = unsafe_ptr_from_HLOCAL( handle ))) + if ((ptr = unsafe_ptr_from_HLOCAL( handle )) && + HeapValidate( heap, HEAP_NO_SERIALIZE, ptr )) { if (flags & LMEM_MODIFY) ret = handle; else