Make sure that psip is deleted after we are done with it.

From: Erik Hovland <erik@hovland.org>


---

 libs/libmythtv/mpeg/mpegstreamdata.cpp |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libs/libmythtv/mpeg/mpegstreamdata.cpp b/libs/libmythtv/mpeg/mpegstreamdata.cpp
index ad07f4f..19e5dea 100644
--- a/libs/libmythtv/mpeg/mpegstreamdata.cpp
+++ b/libs/libmythtv/mpeg/mpegstreamdata.cpp
@@ -1388,6 +1388,7 @@ void MPEGStreamData::DeleteCachedTable(PSIPTable *psip) const
         return;
 
     uint tid = psip->TableIDExtension();
+    bool delete_psip = false;
 
     QMutexLocker locker(&_cache_lock);
     if (_cached_ref_cnt[psip] > 0)
@@ -1399,13 +1400,13 @@ void MPEGStreamData::DeleteCachedTable(PSIPTable *psip) const
              (_cached_pats[(tid << 8) | psip->Section()] == psip))
     {
         _cached_pats[(tid << 8) | psip->Section()] = NULL;
-        delete psip;
+        delete_psip = true;
     }
     else if ((TableID::PMT == psip->TableID()) &&
              (_cached_pmts[(tid << 8) | psip->Section()] == psip))
     {
         _cached_pmts[(tid << 8) | psip->Section()] = NULL;
-        delete psip;
+        delete_psip = true;
     }
     else
     {
@@ -1416,6 +1417,12 @@ void MPEGStreamData::DeleteCachedTable(PSIPTable *psip) const
     it = _cached_slated_for_deletion.find(psip);
     if (it != _cached_slated_for_deletion.end())
         _cached_slated_for_deletion.erase(it);
+
+    if (delete_psip)
+    {
+        delete(psip);
+        psip = NULL;
+    }
 }
 
 void MPEGStreamData::CachePAT(const ProgramAssociationTable *_pat)
