Fix the issue in AddCredential api
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/300
(cherry picked from commit
0538b11eb0600edbf18bc43af4c3493369f99e09)
Change-Id: I0211724897f604ba88dcfb33147cb219a502ef65
Signed-off-by: Vitalii Irkha <v.irkha@samsung.com>
Signed-off-by: Amit KS <amit.s12@samsung.com>
}
else
{
+ OicSecCred_t *prev = NULL;
LL_FOREACH(gCred, temp)
{
CredCompareResult_t cmpRes = CompareCredential(temp, newCred);
OIC_LOG_V(WARNING, TAG, "Detected same credential ID(%d)" \
"new credential's ID will be replaced.", temp->credId);
newCred->credId = temp->credId;
+ newCred->next = temp->next;
+
+ if(NULL == prev)
+ {
+ gCred = newCred;
+ }
+ else
+ {
+ prev->next = newCred;
+ }
+
+ FreeCred(temp);
ret = OC_STACK_OK;
validFlag = false;
break;
validFlag = false;
break;
}
+
+ prev = temp;
}
}