Fix bad frees in error paths of WebRtcAecm_Create
The error paths free the memory referenced by each pointer in the struct, but if the pointers are not initialized, random memory belonging to other parts of the program could be freed instead. Zero out the entire struct as soon as it is allocated to ensure that nothing is freed if there is nothing to free. Bug: webrtc:11446 Change-Id: I8a2985d1388477339351aa03107ee68925372d49 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171121 Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30852}
This commit is contained in:
@ -89,7 +89,8 @@ static int WebRtcAecm_EstBufDelay(AecMobile* aecm, short msInSndCardBuf);
|
||||
static int WebRtcAecm_DelayComp(AecMobile* aecm);
|
||||
|
||||
void* WebRtcAecm_Create() {
|
||||
AecMobile* aecm = static_cast<AecMobile*>(malloc(sizeof(AecMobile)));
|
||||
// Allocate zero-filled memory.
|
||||
AecMobile* aecm = static_cast<AecMobile*>(calloc(1, sizeof(AecMobile)));
|
||||
|
||||
aecm->aecmCore = WebRtcAecm_CreateCore();
|
||||
if (!aecm->aecmCore) {
|
||||
@ -103,8 +104,6 @@ void* WebRtcAecm_Create() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
aecm->initFlag = 0;
|
||||
|
||||
#ifdef AEC_DEBUG
|
||||
aecm->aecmCore->farFile = fopen("aecFar.pcm", "wb");
|
||||
aecm->aecmCore->nearFile = fopen("aecNear.pcm", "wb");
|
||||
|
||||
Reference in New Issue
Block a user