[PORTCLS] Do not rely on operator new to zero memory.

The standard operator new does not do this, and GCC will in fact
optimize out any zeroing done in the operator.
This commit is contained in:
Thomas Faber 2022-01-16 23:02:39 -05:00
parent 418edcd2bf
commit ec1eb52ebf
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
2 changed files with 49 additions and 10 deletions

View file

@ -24,10 +24,7 @@ public:
POOL_TYPE PoolType,
ULONG Tag)
{
PVOID P = ExAllocatePoolWithTag(PoolType, Size, Tag);
if (P)
RtlZeroMemory(P, Size);
return P;
return ExAllocatePoolWithTag(PoolType, Size, Tag);
}
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
@ -49,7 +46,24 @@ public:
return m_Ref;
}
IMP_IDmaChannelInit;
CDmaChannelInit(IUnknown * OuterUnknown){}
CDmaChannelInit(IUnknown * OuterUnknown) :
m_pDeviceObject(nullptr),
m_pAdapter(nullptr),
m_DmaStarted(FALSE),
m_MapSize(0),
m_MapRegisterBase(nullptr),
m_LastTransferCount(0),
m_MaximumBufferSize(0),
m_MaxMapRegisters(0),
m_AllocatedBufferSize(0),
m_BufferSize(0),
m_Address({0}),
m_Buffer(nullptr),
m_Mdl(nullptr),
m_WriteToDevice(FALSE),
m_Ref(0)
{
}
virtual ~CDmaChannelInit(){}
protected:

View file

@ -25,10 +25,7 @@ public:
POOL_TYPE PoolType,
ULONG Tag)
{
PVOID P = ExAllocatePoolWithTag(PoolType, Size, Tag);
if (P)
RtlZeroMemory(P, Size);
return P;
return ExAllocatePoolWithTag(PoolType, Size, Tag);
}
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
@ -51,7 +48,35 @@ public:
}
IMP_IPortPinWaveCyclic;
IMP_IServiceSink;
CPortPinWaveCyclic(IUnknown *OuterUnknown){}
CPortPinWaveCyclic(IUnknown *OuterUnknown) :
m_Port(nullptr),
m_Filter(nullptr),
m_KsPinDescriptor(nullptr),
m_Miniport(nullptr),
m_ServiceGroup(nullptr),
m_DmaChannel(nullptr),
m_Stream(nullptr),
m_State(KSSTATE_STOP),
m_Format(nullptr),
m_ConnectDetails(nullptr),
m_CommonBuffer(nullptr),
m_CommonBufferSize(0),
m_CommonBufferOffset(0),
m_IrpQueue(nullptr),
m_FrameSize(0),
m_Capture(FALSE),
m_TotalPackets(0),
m_StopCount(0),
m_Position({0}),
m_AllocatorFraming({{0}}),
m_Descriptor(nullptr),
m_EventListLock(0),
m_EventList({nullptr}),
m_ResetState(KSRESET_BEGIN),
m_Delay(0),
m_Ref(0)
{
}
virtual ~CPortPinWaveCyclic(){}
protected: