https://git.reactos.org/?p=reactos.git;a=commitdiff;h=76e00fab7e959d4b4acd1…
commit 76e00fab7e959d4b4acd17dababc02f26c2208ef
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Fri Jul 5 17:26:16 2019 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Fri Jul 5 17:31:46 2019 +0200
[PORTCLS] Zero memory in operator new. CORE-16157
Fixes a regression from 99fa38809fd8ed38d4d59fa1fcf3babb3216b895, 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.
---
drivers/wdm/audio/backpln/portcls/dma_slave.cpp | 5 ++++-
drivers/wdm/audio/backpln/portcls/miniport.cpp | 5 ++++-
drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp | 5 ++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/wdm/audio/backpln/portcls/dma_slave.cpp
b/drivers/wdm/audio/backpln/portcls/dma_slave.cpp
index a68d2779128..4a0553b3ba8 100644
--- a/drivers/wdm/audio/backpln/portcls/dma_slave.cpp
+++ b/drivers/wdm/audio/backpln/portcls/dma_slave.cpp
@@ -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);
diff --git a/drivers/wdm/audio/backpln/portcls/miniport.cpp
b/drivers/wdm/audio/backpln/portcls/miniport.cpp
index 526a012c7b1..8f00823770f 100644
--- a/drivers/wdm/audio/backpln/portcls/miniport.cpp
+++ b/drivers/wdm/audio/backpln/portcls/miniport.cpp
@@ -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
diff --git a/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp
b/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp
index 993ea92674b..e57fbefda74 100644
--- a/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp
+++ b/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp
@@ -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);