telephonyserverplugins/common_tsy/commontsy/src/mmtsy/cmmnettsy.cpp
branchRCL_3
changeset 82 042fd2753b8f
parent 66 07a122eea281
--- a/telephonyserverplugins/common_tsy/commontsy/src/mmtsy/cmmnettsy.cpp	Wed Sep 15 13:30:43 2010 +0300
+++ b/telephonyserverplugins/common_tsy/commontsy/src/mmtsy/cmmnettsy.cpp	Wed Oct 13 15:51:46 2010 +0300
@@ -3247,11 +3247,17 @@
 			
 			// if iGetPrefPLMNList, iClientIdGetPrefPLMN, and/or iBufSizeGetPrefPLMN are not NULL, phase 1 is called twice without calling phase 2.
 			// In this case, we should ignore the previous phase 1 and delete buffers.
-			delete iGetPrefPLMNList;
-			iGetPrefPLMNList = NULL;
+			if(iGetPrefPLMNList != NULL)
+				{
+				delete iGetPrefPLMNList;
+				iGetPrefPLMNList = NULL;
+				}
 			iBufSizeGetPrefPLMN = aBufSize;
-			delete iClientIdGetPrefPLMN;
-			iClientIdGetPrefPLMN = NULL;
+			if(iClientIdGetPrefPLMN != NULL)
+				{
+				delete iClientIdGetPrefPLMN;
+				iClientIdGetPrefPLMN = NULL;
+				}
 			// Copy client id (session and subsession handle). it's used for
             // matching phase 1 and 2 of a request
 			iClientIdGetPrefPLMN = new ( ELeave ) RMobilePhone::TClientId( *aId ); 
@@ -3378,10 +3384,16 @@
 	if(CMmPhoneTsy::EMultimodePhoneReqHandleUnknown != reqHandle)
 		{
 		iBufSizeGetPrefPLMN = NULL;
-		delete iClientIdGetPrefPLMN;
-		iClientIdGetPrefPLMN = NULL;
-		delete iGetPrefPLMNList;
-		iGetPrefPLMNList = NULL;
+		if(iClientIdGetPrefPLMN)
+			{
+			delete iClientIdGetPrefPLMN;
+			iClientIdGetPrefPLMN = NULL;
+			}
+		if(iGetPrefPLMNList)
+			{
+			delete iGetPrefPLMNList;
+			iGetPrefPLMNList = NULL;
+			}
         iMmPhoneTsy->ReqCompleted( reqHandle, KErrCancel );        
 		}
 	//if reqHandle is 0, it means  phase 1 has completed and the list retrieval cannot be cancelled
@@ -3440,8 +3452,11 @@
 	if(CMmPhoneTsy::EMultimodePhoneReqHandleUnknown == reqHandle)
 		{
 		TFLOGSTRING("TSY CompleteGetPreferredNetworksListPhase1: reqHandle is 0, cannot complete Phase1 list retrieval request!!");
-		delete iClientIdGetPrefPLMN;
-		iClientIdGetPrefPLMN = NULL;
+		if(iClientIdGetPrefPLMN)
+			{
+			delete iClientIdGetPrefPLMN;
+			iClientIdGetPrefPLMN = NULL;
+			}
 		}
 	else if(KErrNone == aError)
 		{
@@ -3464,6 +3479,7 @@
 				TFLOGSTRING2("TSY CompleteGetPreferredNetworksListPhase1: failed to stream the list into the buffer, error = %d!!", trapError);
 				completeError = trapError;
 				}
+			delete list;
 			}
 		else
 			{
@@ -3480,8 +3496,11 @@
 	if(completeError != KErrNone)
 		{
 		iMmPhoneTsy->ReqCompleted( reqHandle, aError );
-		delete iClientIdGetPrefPLMN;
-		iClientIdGetPrefPLMN = NULL;
+		if(iClientIdGetPrefPLMN)
+			{
+			delete iClientIdGetPrefPLMN;
+			iClientIdGetPrefPLMN = NULL;
+			}
 		}
 	
 	iBufSizeGetPrefPLMN = NULL;