fixed memory leak

This commit is contained in:
Hane 2023-08-24 17:08:22 +02:00
commit 1fcf6c3722
3 changed files with 23 additions and 3 deletions

View file

@ -41,8 +41,20 @@ HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
//TODO: MEMORY LEAK. FREE DATA4 FROM NGUID.
//TODO: el default = objcopy frees?
//delete osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller;
memcpy(&osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller, &pNotify->guidEventContext,sizeof(NGuid) );
//delete osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller;
//osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.freeData4();
//Could've made a function or = override to hide this within Nguid, but back in cont = bad.
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data1 \
= pNotify->guidEventContext.Data1;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data2 \
= pNotify->guidEventContext.Data2;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data3 \
= pNotify->guidEventContext.Data3;
for(int i = 0; i < 8 /* Data4 size */; i++){
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data4[i] = pNotify->guidEventContext.Data4[i];
}
//memcpy(&osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller, &pNotify->guidEventContext,sizeof(NGuid) );
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->muted = pNotify->bMuted;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->mainVolume = pNotify->fMasterVolume;