if (gatewayId == g_GatewayID)
{
OC_LOG(INFO, TAG, "-------------->Own entry, continue!!");
+ RTMFreeGatewayRouteTable(&gatewayTableList);
return OC_STACK_ERROR;
}
// Convert OCDevAddr to endpoint address
OC_LOG(ERROR, TAG, "Few packet drops are found, sequence number is not matching");
// Send a observe request to the gateway.
RMSendObserveRequest(devAddr, NULL);
+ RTMFreeGatewayRouteTable(&gatewayTableList);
return result;
}
else if (OC_STACK_DUPLICATE_REQUEST == result)
{
OC_LOG(ERROR, TAG, "Same sequence number is received");
+ RTMFreeGatewayRouteTable(&gatewayTableList);
return result;
}
}
// Create a list to add the updated entries and notify the observers
u_linklist_t *updatedTableList = u_linklist_create();
+ if(!updatedTableList)
+ {
+ OC_LOG(DEBUG, TAG, "Failed to allocate memory");
+ return OC_STACK_NO_MEMORY;
+ }
+
u_linklist_t *alternativeRouteList = u_linklist_create();
+ if(!alternativeRouteList)
+ {
+ OC_LOG(DEBUG, TAG, "Failed to allocate memory");
+ return OC_STACK_NO_MEMORY;
+ }
+
OCRepPayload *updatedPayload = NULL;
if (false == doRemoveEntry)
{
if (OC_STACK_OK != result)
{
OC_LOG_V(DEBUG, TAG, "Send response failed[%d]", result);
+ RMPFreePayload(payload);
return result;
}
for (uint32_t i = 0; i < u_arraylist_length(entry->destination->destIntfAddr); i++)
{
RTMDestIntfInfo_t *dest = u_arraylist_get(entry->destination->destIntfAddr, i);
+ if (!dest)
+ {
+ OC_LOG(ERROR, RM_TAG, "Failed to get dest address");
+ continue;
+ }
OCDevAddr devAddr = {.adapter = OC_DEFAULT_ADAPTER};
CopyEndpointToDevAddr(&(dest->destIntfAddr), &devAddr);
OC_LOG_V(DEBUG, TAG, "\nDestination interface addresses: %s[%d], OCDevAddr: %s[%d]",
RMSendDeleteRequest(&devAddr, payload);
}
}
- RMPFreePayload(payload);
+
u_linklist_get_next(&iterTable);
}
if (NULL == *gatewayTable)
{
*gatewayTable = u_linklist_create();
+ if (NULL == *gatewayTable)
+ {
+ OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ return OC_STACK_NO_MEMORY;
+ }
}
if (1 == routeCost && 0 != nextHop)
if (NULL == *endpointTable)
{
*endpointTable = u_linklist_create();
+ if (NULL == *endpointTable)
+ {
+ OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ return OC_STACK_NO_MEMORY;
+ }
}
u_linklist_iterator_t *iterTable = NULL;
if (NULL == *removedGatewayNodes)
{
*removedGatewayNodes = u_linklist_create();
+ if (NULL == *removedGatewayNodes)
+ {
+ OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ return OC_STACK_NO_MEMORY;
+ }
}
OCStackResult ret = OC_STACK_OK;
u_linklist_init_iterator(*gatewayTable, &iterTable);
for (uint32_t i = 0; i < u_arraylist_length(entry->destination->destIntfAddr); i++)
{
RTMDestIntfInfo_t *destCheck = u_arraylist_get(entry->destination->destIntfAddr, i);
+ if(!destCheck)
+ {
+ continue;
+ }
if (0 == memcmp(destCheck->destIntfAddr.addr, destInfAdr->destIntfAddr.addr,
strlen(destInfAdr->destIntfAddr.addr))
&& destInfAdr->destIntfAddr.port == destCheck->destIntfAddr.port)
RM_NULL_CHECK_VOID(gatewayTable, TAG, "gatewayTable");
*neighbourNodes = u_linklist_create();
+ if (NULL == *neighbourNodes)
+ {
+ OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ return;
+ }
u_linklist_iterator_t *iterTable = NULL;
u_linklist_init_iterator(gatewayTable, &iterTable);
while (NULL != iterTable)
{
RTMDestIntfInfo_t *removeAdr =
u_arraylist_get(entry->destination->destIntfAddr, i);
+ if (!removeAdr)
+ {
+ continue;
+ }
if (0 == memcmp(removeAdr->destIntfAddr.addr, destInterfaces.destIntfAddr.addr,
strlen(destInterfaces.destIntfAddr.addr))
&& destInterfaces.destIntfAddr.port == removeAdr->destIntfAddr.port)
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
*invalidTable = u_linklist_create();
+ if (NULL == *invalidTable)
+ {
+ OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ return OC_STACK_NO_MEMORY;
+ }
+
u_linklist_iterator_t *iterTable = NULL;
uint64_t presentTime = RTMGetCurrentTime();
for (uint32_t i = 0; i < u_arraylist_length(entry->destination->destIntfAddr); i++)
{
RTMDestIntfInfo_t *destCheck = u_arraylist_get(entry->destination->destIntfAddr, i);
+ if (!destCheck)
+ {
+ continue;
+ }
if (GATEWAY_ALIVE_TIMEOUT < (presentTime - destCheck->timeElapsed))
{
destCheck->isValid = false;
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
*invalidTable = u_linklist_create();
+ if (NULL == *invalidTable)
+ {
+ OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ return OC_STACK_NO_MEMORY;
+ }
u_linklist_iterator_t *iterTable = NULL;
u_linklist_init_iterator(*gatewayTable, &iterTable);
for (uint32_t i = 0; i < u_arraylist_length(entry->destination->destIntfAddr); i++)
{
RTMDestIntfInfo_t *destCheck = u_arraylist_get(entry->destination->destIntfAddr, i);
- if (!destCheck->isValid)
+ if (!destCheck && !destCheck->isValid)
{
void *data = u_arraylist_remove(entry->destination->destIntfAddr, i);
OICFree(data);