user32: Fix a memory allocation strategy.

Otherwise, the function allocates a heap memory when prev_size is enough.
What is worse is that it returns the buffer untouched if the prev_size
is insufficient.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53703
This commit is contained in:
Akihiro Sagawa 2022-09-19 22:10:24 +09:00 committed by Alexandre Julliard
parent 548a6afccb
commit cb0e4f5f4f

View file

@ -747,7 +747,8 @@ void dispatch_win_proc_params( struct win_proc_params *params )
/* make sure that there is space for 'size' bytes in buffer, growing it if needed */
static inline void *get_buffer_space( void **buffer, size_t size, size_t prev_size )
{
if (prev_size > size && !(*buffer = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL;
if (prev_size < size)
*buffer = HeapAlloc( GetProcessHeap(), 0, size );
return *buffer;
}