bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp
branchRCL_3
changeset 21 0ba996a9b75d
parent 15 53b7818cd282
--- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp	Thu Jul 15 18:50:18 2010 +0300
+++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp	Thu Aug 19 10:05:41 2010 +0300
@@ -399,21 +399,23 @@
         {
         return;
         }
-    TBuf8<KDefaultCmdBufLength> cmddes;
-    if (iInDataBuf.NextCommand(cmddes))
+    RBuf8 cmddes;
+    cmddes.CreateL(KDefaultCmdBufLength);
+    CleanupClosePushL(cmddes);
+    if (iInDataBuf.NextCommand(cmddes) || cmddes.Length() == 0)
         {
+        CleanupStack::PopAndDestroy(&cmddes);
         return;
         }
-    if (cmddes.Length() == 0)
-        {
-        return;
-        }
+    
     TRACE_INFO_SEG(
         {
-        TBuf8<KDefaultCmdBufLength> buf;
+        RBuf8 buf;
+        buf.CreateL(KDefaultCmdBufLength);
         buf = cmddes;
         buf.Trim();
         Trace(_L8("[HFP] [I] %S"), &buf);
+        buf.Close();
         })
 
     CATCommand* cmd = NULL;
@@ -423,13 +425,16 @@
       	if(iAtExt)
         	{
       		iAtExt->HandleCommand(cmddes, _L8("\n\rERROR\n\r"));
+      		CleanupStack::PopAndDestroy(&cmddes);
         	return;
         	}
         CATResult* nok = CATResult::NewLC(EATERROR);
         SendResponseL(*nok);
         CleanupStack::PopAndDestroy(nok);
+        CleanupStack::PopAndDestroy(&cmddes);
         return;
         }
+    CleanupStack::PopAndDestroy(&cmddes);
     CleanupStack::PushL(cmd);
     iHandleCmdPending = ETrue;
 	TATId id = cmd->Id();
@@ -1080,14 +1085,17 @@
     {
     TRACE_INFO((_L("credit %d"), iCredit))
     TInt count = iOutgoPacketQueue->MdcaCount();
+    RBuf8 buf;
+    buf.CreateL(KDefaultCmdBufLength);
+    CleanupClosePushL(buf);
     for (TInt i = 0; iCredit >0 && i < count; i++)
         {
         iCredit--;
-        TBuf8<KDefaultCmdBufLength> buf;
         buf.Copy(iOutgoPacketQueue->MdcaPoint(0));
         iObserver.SendProtocolDataL(buf);
         iOutgoPacketQueue->Delete(0);
         }
+    CleanupStack::PopAndDestroy(&buf);
     }
 
 void CBtmcProtocol::StartTimerL(TInt aService, TInt aTimeout)