tspacket_fake should be deleted whenever the function

From: Erik Hovland <erik@hovland.org>

returns.
---

 libs/libmythtv/mpegrecorder.cpp |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/libs/libmythtv/mpegrecorder.cpp b/libs/libmythtv/mpegrecorder.cpp
index 50d2045..224d554 100644
--- a/libs/libmythtv/mpegrecorder.cpp
+++ b/libs/libmythtv/mpegrecorder.cpp
@@ -15,7 +15,9 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
 
+// C++ headers
 #include <algorithm>
+#include <memory>
 using namespace std;
 
 // avlib headers
@@ -1034,17 +1036,17 @@ bool MpegRecorder::ProcessTSPacket(const TSPacket &tspacket_real)
 {
     const uint pid = tspacket_real.PID();
 
-    TSPacket *tspacket_fake = NULL;
+    auto_ptr<TSPacket> tspacket_fake(NULL);
     if ((driver == "hdpvr") && (pid == 0x1001)) // PCRPID for HD-PVR
     {
-        tspacket_fake = tspacket_real.CreateClone();
+        tspacket_fake.reset(tspacket_real.CreateClone());
         uint cc = (_continuity_counter[pid] == 0xFF) ?
             0 : (_continuity_counter[pid] + 1) & 0xf;
         tspacket_fake->SetContinuityCounter(cc);
     }
 
-    const TSPacket *tspacket = (tspacket_fake) ?
-        tspacket_fake : &tspacket_real;
+    const TSPacket *tspacket = (tspacket_fake.get()) ?
+        tspacket_fake.get() : &tspacket_real;
 
     // Check continuity counter
     if ((pid != 0x1fff) && !CheckCC(pid, tspacket->ContinuityCounter()))
@@ -1063,9 +1065,6 @@ bool MpegRecorder::ProcessTSPacket(const TSPacket &tspacket_real)
 
     BufferedWrite(*tspacket);
 
-    if (tspacket_fake)
-        delete tspacket_fake;
-
     return true;
 }
 

