From e7e7272d5228a845595ae0b54966140ed5ed5da6 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 27 Dec 2018 14:23:54 +0100 Subject: [PATCH] Fix memory leaks as result of missing delete[] The delete keyword only calls a single destructor, delete[] calls as many as there are members in the array. --- src/overlaycontroller.cpp | 4 ++-- src/tabcontrollers/ChaperoneTabController.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index a85891f..c0195dc 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -593,7 +593,7 @@ void OverlayController::AddOffsetToCollisionBounds(float offset[3], bool commit) } } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); - delete collisionBounds; + delete[] collisionBounds; } if (commit && collisionBoundsCount > 0) { vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); @@ -621,7 +621,7 @@ void OverlayController::RotateCollisionBounds(float angle, bool commit) { } } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); - delete collisionBounds; + delete[] collisionBounds; } if (commit && collisionBoundsCount > 0) { vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); diff --git a/src/tabcontrollers/ChaperoneTabController.cpp b/src/tabcontrollers/ChaperoneTabController.cpp index 92572bf..ce706ef 100644 --- a/src/tabcontrollers/ChaperoneTabController.cpp +++ b/src/tabcontrollers/ChaperoneTabController.cpp @@ -486,7 +486,7 @@ void ChaperoneTabController::setHeight(float value, bool notify) { } vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount); vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live); - delete collisionBounds; + delete[] collisionBounds; } if (notify) { emit heightChanged(m_fadeDistance); @@ -1006,7 +1006,7 @@ float ChaperoneTabController::getBoundsMaxY() { result = collisionBounds[b].vCorners[ci].v[1]; } } - delete collisionBounds; + delete[] collisionBounds; } return result; }