cec: safe deletes for members
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index b192391906607f0da79ea1cb377aa3aa375256b5..3377960993531ed674a5dd21b7c28873c2f68276 100644 (file)
@@ -38,6 +38,7 @@
 #include "../implementations/VLCommandHandler.h"
 #include "../LibCEC.h"
 #include "../platform/util/timeutils.h"
+#include "../platform/util/util.h"
 
 #include "CECAudioSystem.h"
 #include "CECPlaybackDevice.h"
@@ -83,7 +84,7 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi
 
 CCECBusDevice::~CCECBusDevice(void)
 {
-  delete m_handler;
+  DELETE_AND_NULL(m_handler);
 }
 
 bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */)
@@ -105,7 +106,7 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */)
       if (CCECCommandHandler::HasSpecificHandler(m_vendor))
       {
         LIB_CEC->AddLog(CEC_LOG_DEBUG, "replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress());
-        delete m_handler;
+        DELETE_AND_NULL(m_handler);
 
         switch (m_vendor)
         {