[PATCH] msvcrtd: Allow new to allocated a _CRT_BLOCK block

Piotr Caban piotr.caban at gmail.com
Thu Apr 5 12:14:21 CDT 2018


Hi Alistair,

On 04/04/18 02:26, Alistair Leslie-Hughes wrote:
> @@ -52,6 +52,7 @@ void * CDECL MSVCRTD_operator_new_dbg(MSVCRT_size_t nSize, int nBlockUse,
>       switch(_BLOCK_TYPE(nBlockUse))
>       {
>       case _NORMAL_BLOCK:
> +    case _CRT_BLOCK:
>           break;
>       case _CLIENT_BLOCK:
>           FIXME("Unimplemented case for nBlockUse = _CLIENT_BLOCK\n");
> @@ -59,7 +60,6 @@ void * CDECL MSVCRTD_operator_new_dbg(MSVCRT_size_t nSize, int nBlockUse,
>       case _FREE_BLOCK:
>           FIXME("Native code throws an exception here\n");
>           return NULL;
> -    case _CRT_BLOCK:
>       case _IGNORE_BLOCK:
>           ERR("Not allowed nBlockUse value: %d\n", _BLOCK_TYPE(nBlockUse));
>           return NULL;
Is there a reason for not calling msvcrt.operator_new_dbg instead of 
implementing the function here? We don't have proper operator_new_dbg 
implementation anyway. According to my tests it's also possible to 
allocate _IGNORE_BLOCK. _FREE_BLOCK is terminating the app in msvcrtd 
case and works in msvcrt (I don't expect any application to depend on 
that behavior).

> +  mem = pMSVCRTD_operator_new_dbg(42, _CRT_BLOCK, __FILE__, __LINE__);
> +  ok(mem != NULL, "memory not allocated\n");
> +  HeapFree(GetProcessHeap(), 0, mem);
You can't free the memory that way. Please call operator delete.

Thanks,
Piotr



More information about the wine-devel mailing list