[PORTCLS] Zero memory in operator new. CORE-16157

Fixes a regression from 99fa38809f, which
replaced the kcom.h/stdunk.h versions (which zero memory) with local
implementations (which don't).

Standard C++ does not guarantee that memory is zeroed but several classes
rely on this, in particular for their m_Ref and m_bInitialized members.

Ideally the constructors should be fixed to initialize all required members,
but that task is error-prone so for now we simply restore the previous
behavior.
This commit is contained in:
Thomas Faber 2019-07-05 17:26:16 +02:00
parent 595ae4c551
commit 76e00fab7e
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
3 changed files with 12 additions and 3 deletions

View file

@ -24,7 +24,10 @@ public:
POOL_TYPE PoolType,
ULONG Tag)
{
return ExAllocatePoolWithTag(PoolType, Size, Tag);
PVOID P = ExAllocatePoolWithTag(PoolType, Size, Tag);
if (P)
RtlZeroMemory(P, Size);
return P;
}
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);

View file

@ -21,7 +21,10 @@ operator new(
POOL_TYPE PoolType,
ULONG Tag)
{
return ExAllocatePoolWithTag(PoolType, Size, Tag);
PVOID P = ExAllocatePoolWithTag(PoolType, Size, Tag);
if (P)
RtlZeroMemory(P, Size);
return P;
}
void

View file

@ -25,7 +25,10 @@ public:
POOL_TYPE PoolType,
ULONG Tag)
{
return ExAllocatePoolWithTag(PoolType, Size, Tag);
PVOID P = ExAllocatePoolWithTag(PoolType, Size, Tag);
if (P)
RtlZeroMemory(P, Size);
return P;
}
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);