IOT-1811 Move MOT device info cleanup to fix AV
authorAlex Kelley <alexke@microsoft.com>
Thu, 9 Feb 2017 02:16:46 +0000 (18:16 -0800)
committerKevin Kane <kkane@microsoft.com>
Tue, 14 Feb 2017 01:11:16 +0000 (01:11 +0000)
Change-Id: Ia7ce7aca7224da855776b47a46749c0baed18b39
Signed-off-by: Alex Kelley <alexke@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17163
Reviewed-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Kevin Kane <kkane@microsoft.com>
resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c

index 20dcfad..4e7757d 100644 (file)
@@ -113,6 +113,7 @@ static OCStackApplicationResult MOTUpdateSecurityResourceCB(void *ctx, OCDoHandl
 exit:
     if(motCtx)
     {
+        PMDeleteDeviceList(motCtx->selectedDeviceInfo);
         OICFree(motCtx->ctxResultArray);
         OICFree(motCtx);
     }
@@ -187,15 +188,11 @@ exit:
     //If POST request successfully sent, motCtx will be cleaned from response handler.
     if(freeFlag && motCtx)
     {
+        PMDeleteDeviceList(motCtx->selectedDeviceInfo);
         OICFree(motCtx->ctxResultArray);
         OICFree(motCtx);
     }
 
-    if (localTargetDeviceInfo)
-    {
-        PMDeleteDeviceList(localTargetDeviceInfo);
-    }
-
     return postMomRes;
 }
 
@@ -467,20 +464,17 @@ exit:
     //If POST request successfully sent, motCtx will be cleaned from response handler.
     if(freeFlag && motCtx)
     {
+        PMDeleteDeviceList(motCtx->selectedDeviceInfo);
         OICFree(motCtx->ctxResultArray);
         OICFree(motCtx);
     }
+
     if(pinCred)
     {
         OICFree(pinCred->privateData.data);
         OICFree(pinCred);
     }
 
-    if (localTargetDeviceInfo)
-    {
-        PMDeleteDeviceList(localTargetDeviceInfo);
-    }
-
     return postCredRes;
 }