msvcrt: Respect allocation mode in malloc.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2020-01-29 14:27:25 +01:00 committed by Alexandre Julliard
parent 1b5a551324
commit 70ac780e6e
1 changed files with 12 additions and 4 deletions

View File

@ -441,10 +441,18 @@ void CDECL _free_base(void* ptr)
*/
void* CDECL MSVCRT_malloc(MSVCRT_size_t size)
{
void *ret = msvcrt_heap_alloc(0, size);
if (!ret)
*MSVCRT__errno() = MSVCRT_ENOMEM;
return ret;
void *ret;
do
{
ret = msvcrt_heap_alloc(0, size);
if (ret || !MSVCRT_new_mode)
break;
} while(_callnewh(size));
if (!ret)
*MSVCRT__errno() = MSVCRT_ENOMEM;
return ret;
}
#if _MSVCR_VER>=140