Prevent and Klockwork Fixes in Routingmanager and CA
authorvimala.v <vimala.v@samsung.com>
Tue, 6 Oct 2015 03:37:10 +0000 (09:07 +0530)
committerPatrick Lankswert <patrick.lankswert@intel.com>
Tue, 6 Oct 2015 12:50:52 +0000 (12:50 +0000)
As cherry-pick from master branch failed,
following commits are pushed as a standalone commit to 1.0.0-dev branch.
1) https://gerrit.iotivity.org/gerrit/#/c/2867/
2) https://gerrit.iotivity.org/gerrit/#/c/3277/
3) https://gerrit.iotivity.org/gerrit/#/c/2807/

Change-Id: I3a66dae476509f0f57995d8792e49ed5a5b6fe94
Signed-off-by: vimala.v <vimala.v@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3563
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Abhishek Pandey <abhi.siso@samsung.com>
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
12 files changed:
resource/csdk/connectivity/common/src/ulinklist.c
resource/csdk/connectivity/samples/arduino/casample.cpp
resource/csdk/connectivity/samples/tizen/casample.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/arduino/caipserver_eth.cpp
resource/csdk/connectivity/src/ip_adapter/arduino/caipserver_wifi.cpp
resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c
resource/csdk/routing/src/routingmanager.c
resource/csdk/routing/src/routingmessageparser.c
resource/csdk/routing/src/routingtablemanager.c
resource/csdk/stack/src/ocstack.c

index 7a87de1..e75c49f 100644 (file)
@@ -181,8 +181,11 @@ CAResult_t u_linklist_remove(u_linklist_t *linklist, u_linklist_iterator_t **ite
 
 uint32_t u_linklist_length(const u_linklist_t *linklist)
 {
-    VERIFY_NON_NULL(linklist, TAG, "list is null");
-
+    if (NULL == linklist)
+    {
+        OIC_LOG(ERROR, TAG, "linklist is NULL");
+        return 0;
+    }
     return linklist->size;
 }
 
index b3011d1..273ed08 100644 (file)
@@ -341,6 +341,7 @@ void SendRequest()
     if (res != CA_STATUS_OK || (!token))
     {
         Serial.println("token error");
+        CADestroyEndpoint(endpoint);
         return;
     }
 
@@ -425,6 +426,7 @@ void SendRequestAll()
     if (res != CA_STATUS_OK || (!token))
     {
         Serial.println("token error");
+        CADestroyEndpoint(endpoint);
         return;
     }
 
@@ -508,6 +510,7 @@ void SendNotification()
     if (res != CA_STATUS_OK || (!token))
     {
         Serial.println("token error");
+        CADestroyEndpoint(endpoint);
         return;
     }
 
index c8dccab..162b512 100644 (file)
@@ -680,7 +680,6 @@ void send_request_all()
     if (CA_STATUS_OK != res)
     {
         printf("Could not send request to all\n");
-        CADestroyEndpoint(endpoint);
     }
     else
     {
index 04dec57..fd0be7e 100644 (file)
@@ -1371,6 +1371,7 @@ static void CASendErrorInfo(const CAEndpoint_t *endpoint, const CAInfo_t *info,
     if (CA_STATUS_OK != res)
     {
         OICFree(cadata);
+        OICFree(errorInfo);
         CAFreeEndpoint(ep);
         return;
     }
index 4fbeeeb..544f561 100755 (executable)
@@ -378,5 +378,11 @@ Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *env, jclass class)
     (void)class;
     OIC_LOG(DEBUG, TAG, "caIpStateDisabled");
 
-    CAIPGetInterfaceInformation(0);
+    u_arraylist_t *iflist = CAIPGetInterfaceInformation(0);
+    if (!iflist)
+    {
+        OIC_LOG_V(ERROR, TAG, "get interface info failed");
+        return;
+    }
+    u_arraylist_destroy(iflist);
 }
index b28c7e5..d8ac060 100644 (file)
@@ -362,7 +362,10 @@ CAResult_t CAGetIPInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
     for (uint32_t i = 0, j = 0; i < len; i++)
     {
         CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
-
+        if(!ifitem)
+        {
+            continue;
+        }
         unsigned char *addr=  (unsigned char *) &(ifitem->ipv4addr);
         snprintf(eps[j].addr, MAX_ADDR_STR_SIZE_CA, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
 
index a3da9a3..f139af8 100644 (file)
@@ -296,7 +296,10 @@ CAResult_t CAGetIPInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
     for (uint32_t i = 0, j = 0; i < len; i++)
     {
         CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
-
+        if(!ifitem)
+        {
+            continue;
+        }
         unsigned char *addr=  (unsigned char *) &(ifitem->ipv4addr);
         snprintf(eps[j].addr, MAX_ADDR_STR_SIZE_CA, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
 
index 47e11b4..88427f3 100644 (file)
@@ -368,6 +368,7 @@ void CAWIFIConnectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap,
             OIC_LOG_V(ERROR, TAG, "get interface info failed");
             return;
         }
+        u_arraylist_destroy(iflist);
     }
 
     OIC_LOG(DEBUG, TAG, "OUT");
index 7eadb23..41024e4 100644 (file)
@@ -316,11 +316,16 @@ OCStackResult RMHandleRequestPayload(OCDevAddr devAddr, const uint8_t *reqPayloa
     result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
                                            updatedTableList, false,
                                            &updatedPayload);
-    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+    if (OC_STACK_OK != result)
+    {
+        OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+        RMPFreePayload(updatedPayload);
+        goto exit;
+    }
 
     result = RMSendNotificationToAll(updatedPayload);
-    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
     RMPFreePayload(updatedPayload);
+    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
 
 exit:
     u_linklist_free(&updatedTableList);
@@ -346,6 +351,7 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
     if (gatewayId == g_GatewayID)
     {
         OC_LOG(INFO, TAG, "-------------->Own entry, continue!!");
+        RTMFreeGatewayRouteTable(&gatewayTableList);
         return OC_STACK_ERROR;
     }
     // Convert OCDevAddr to endpoint address
@@ -364,11 +370,13 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
             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;
         }
     }
@@ -388,7 +396,19 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
 
     // 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)
     {
@@ -411,6 +431,7 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
                 result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
                                                        updatedTableList, false,
                                                        &updatedPayload);
+                RM_VERIFY_SUCCESS(result, OC_STACK_OK);
                 goto sendNotification;
             }
         }
@@ -470,15 +491,21 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
         result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
                                                alternativeRouteList, false,
                                                &removeTablePayload);
-        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+        if (OC_STACK_OK != result)
+        {
+            OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+            RMPFreePayload(removeTablePayload);
+            goto exit;
+        }
         result = RMSendNotificationToAll(removeTablePayload);
-        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
         RMPFreePayload(removeTablePayload);
+        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
     }
 
     if ( 0 >= u_linklist_length(updatedTableList))
     {
-        OC_LOG_V(DEBUG, TAG, "No updation is needed, Length is %d", u_linklist_length(updatedTableList));
+        OC_LOG_V(DEBUG, TAG, "No updation is needed, Length is %d",
+                 u_linklist_length(updatedTableList));
         goto exit;
     }
 
@@ -499,11 +526,11 @@ OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPaylo
 sendNotification:
     result = RMSendNotificationToAll(updatedPayload);
     RM_VERIFY_SUCCESS(result, OC_STACK_OK);
-    RMPFreePayload(updatedPayload);
 
 exit:
+    RMPFreePayload(updatedPayload);
+    RTMFreeGatewayRouteTable(&gatewayTableList);
     u_linklist_free(&updatedTableList);
-    u_linklist_free(&gatewayTableList);
     u_linklist_free(&alternativeRouteList);
     OC_LOG(DEBUG, TAG, "RMHandleResponsePayload OUT");
     return OC_STACK_OK;
@@ -528,11 +555,11 @@ OCStackResult RMHandleGETRequest(const OCServerRequest *request, const OCResourc
     if (OC_STACK_OK != result)
     {
         OC_LOG_V(DEBUG, TAG, "Send response failed[%d]", result);
+        RMPFreePayload(payload);
         return result;
     }
 
     RMPFreePayload(payload);
-
     // Send a observe request
     result = RMSendObserveRequest(&(request->devAddr), NULL);
     if (OC_STACK_OK != result)
@@ -569,11 +596,16 @@ OCStackResult RMHandleOBSERVERequest(OCServerRequest *request, const OCResource
     result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
                                            g_routingGatewayTable, true,
                                            &payload);
-    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+    if (OC_STACK_OK != result)
+    {
+        OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+        RMPFreePayload(payload);
+        goto exit;
+    }
 
     result = RMSendResponse(request, resource, payload);
-    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
     RMPFreePayload(payload);
+    RM_VERIFY_SUCCESS(result, OC_STACK_OK);
 exit:
     OC_LOG(DEBUG, TAG, "RMHandleOBSERVERequest OUT");
     return result;
@@ -603,14 +635,20 @@ OCStackResult RMHandleDELETERequest(const OCServerRequest *request, const OCReso
         g_sequenceNumber++;
         result = RMPConstructRemovalPayload(g_GatewayID, g_sequenceNumber, removedGatewayNodes,
                                             false, &resPayloads);
-        RTMFreeGatewayRouteTable(&removedGatewayNodes);
-        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+        if (OC_STACK_OK != result)
+        {
+            OC_LOG_V(ERROR, TAG, "RMPConstructRemovalPayload failed[%d]", result);
+            RMPFreePayload(resPayloads);
+            goto exit;
+        }
         result = RMSendNotificationToAll(resPayloads);
+        RMPFreePayload(resPayloads);
         RM_VERIFY_SUCCESS(result, OC_STACK_OK);
         RTMPrintTable(g_routingGatewayTable, g_routingEndpointTable);
     }
 
 exit:
+    RTMFreeGatewayRouteTable(&removedGatewayNodes);
     OC_LOG(DEBUG, TAG, "RMHandleDELETERequest OUT");
     return result;
 }
@@ -692,11 +730,16 @@ void RMProcess()
         OCRepPayload *payload = NULL;
         result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber, NULL,
                                                false, &payload);
-        RM_VERIFY_SUCCESS(result, OC_STACK_OK);
-
+        if (OC_STACK_OK != result)
+        {
+            OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+            RMPFreePayload(payload);
+            goto exit;
+        }
         OC_LOG(DEBUG, TAG, "Sending the alive notification to all");
         // Send notification for every 15s to all the neighbours.
         result = RMSendNotificationToAll(payload);
+        RMPFreePayload(payload);
         RM_VERIFY_SUCCESS(result, OC_STACK_OK);
     }
 
@@ -713,13 +756,20 @@ void RMProcess()
             result = RMPConstructRemovalPayload(g_GatewayID, g_sequenceNumber, removedEntries,
                                                 false, &resPayloads);
             RTMFreeGatewayRouteTable(&removedEntries);
-            RM_VERIFY_SUCCESS(result, OC_STACK_OK);
+            if (OC_STACK_OK != result)
+            {
+                OC_LOG_V(ERROR, TAG, "RMPConstructRemovalPayload failed[%d]", result);
+                RMPFreePayload(resPayloads);
+                goto exit;
+            }
             result = RMSendNotificationToAll(resPayloads);
+            RMPFreePayload(resPayloads);
             RM_VERIFY_SUCCESS(result, OC_STACK_OK);
             RTMPrintTable(g_routingGatewayTable, g_routingEndpointTable);
         }
         g_refreshTableTime = currentTime;
         g_isValidated = false;
+        u_linklist_free(&removedEntries);
         goto exit;
     }
 
@@ -787,6 +837,7 @@ void RMSendDeleteToNeighbourNodes()
         if (OC_STACK_OK != result)
         {
             OC_LOG_V(DEBUG, TAG, "RMPConstructGatewayPayload failed[%d]", result);
+            RMPFreePayload(payload);
             u_linklist_free(&neighbourNodes);
             return;
         }
@@ -797,6 +848,11 @@ void RMSendDeleteToNeighbourNodes()
             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]",
@@ -804,6 +860,7 @@ void RMSendDeleteToNeighbourNodes()
                 RMSendDeleteRequest(&devAddr, payload);
             }
         }
+
         u_linklist_get_next(&iterTable);
     }
 
index bcaba17..323b3aa 100644 (file)
@@ -222,7 +222,7 @@ OCStackResult RMPParseRequestPayload(const uint8_t* payload, size_t payloadSize,
                                      uint32_t *gatewayId)
 {
     OCPayload *ocPayload = NULL;
-    OCParsePayload(&ocPayload, payload, payloadSize);
+    OCParsePayload(&ocPayload, PAYLOAD_TYPE_REPRESENTATION, payload, payloadSize);
     OCRepPayload *repPayload = (OCRepPayload *)ocPayload;
     OCStackResult res = RMPParseResponsePayload(repPayload, gatewayId, NULL, NULL, NULL);
     if (OC_STACK_OK != res)
@@ -274,7 +274,7 @@ OCStackResult RMPParseResponsePayload(const OCRepPayload *payload, uint32_t *gat
 
     if (NULL == gatewayTable)
     {
-        OC_LOG(DEBUG, TAG, "Parsed Request Payload");
+        OC_LOG(DEBUG, TAG, "gatewayTable is NULL");
         return OC_STACK_OK;
     }
 
@@ -317,8 +317,8 @@ OCStackResult RMPParseResponsePayload(const OCRepPayload *payload, uint32_t *gat
         if (NULL == entry->nextHop)
         {
             OC_LOG(DEBUG, TAG, "nextHop Calloc failed");
-            OICFree(entry);
             OICFree(entry->destination);
+            OICFree(entry);
             return OC_STACK_ERROR;
         }
 
index 5f5d9a4..d9d76f7 100644 (file)
@@ -240,6 +240,11 @@ OCStackResult RTMAddGatewayEntry(uint32_t gatewayId, uint32_t nextHop, uint32_t
     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)
@@ -504,6 +509,11 @@ OCStackResult RTMAddEndpointEntry(uint16_t *endpointId, const CAEndpoint_t *dest
     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;
@@ -636,6 +646,11 @@ OCStackResult RTMRemoveGatewayEntry(uint32_t gatewayId, u_linklist_t **removedGa
     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);
@@ -700,6 +715,10 @@ OCStackResult RTMRemoveGatewayDestEntry(uint32_t gatewayId, uint32_t nextHop,
             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)
@@ -829,6 +848,11 @@ void RTMGetNeighbours(u_linklist_t **neighbourNodes, const u_linklist_t *gateway
     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)
@@ -931,9 +955,9 @@ void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
     while (NULL != iterTable)
     {
         RTMGatewayEntry_t *entry = u_linklist_get_data(iterTable);
-        for (uint32_t i = 0; i < u_arraylist_length(entry->destination->destIntfAddr); i++)
+        if (0 < u_arraylist_length(entry->destination->destIntfAddr))
         {
-            RTMDestIntfInfo_t *destCheck = u_arraylist_get(entry->destination->destIntfAddr, i);
+            RTMDestIntfInfo_t *destCheck = u_arraylist_get(entry->destination->destIntfAddr, 0);
             if (NULL == destCheck)
             {
                 OC_LOG(ERROR, TAG, "destCheck is null");
@@ -950,7 +974,6 @@ void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
                 *obsList = (OCObservationId *) OICRealloc((void *)*obsList,
                            (sizeof(OCObservationId) * (len + 1)));
             }
-            break;
         }
         u_linklist_get_next(&iterTable);
     }
@@ -1023,6 +1046,10 @@ OCStackResult RTMUpdateDestinationIntfAdr(uint32_t gatewayId, RTMDestIntfInfo_t
             {
                 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)
@@ -1109,6 +1136,12 @@ OCStackResult RTMUpdateDestAddrValidity(u_linklist_t **invalidTable, u_linklist_
     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();
 
@@ -1126,6 +1159,10 @@ OCStackResult RTMUpdateDestAddrValidity(u_linklist_t **invalidTable, u_linklist_
             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;
@@ -1151,6 +1188,11 @@ OCStackResult RTMRemoveInvalidGateways(u_linklist_t **invalidTable, u_linklist_t
     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);
@@ -1168,7 +1210,7 @@ OCStackResult RTMRemoveInvalidGateways(u_linklist_t **invalidTable, u_linklist_t
             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);
index 530a4bf..cf2ccb8 100644 (file)
@@ -1173,6 +1173,12 @@ void HandleCAResponses(const CAEndpoint_t* endPoint, const CAResponseInfo_t* res
                     {
                         type = PAYLOAD_TYPE_PLATFORM;
                     }
+#ifdef ROUTING_GATEWAY
+                    else if (strcmp(cbNode->requestUri, OC_RSRVD_GATEWAY_URI) == 0)
+                    {
+                        type = PAYLOAD_TYPE_REPRESENTATION;
+                    }
+#endif
                     else if (strcmp(cbNode->requestUri, OC_RSRVD_RD_URI) == 0)
                     {
                         type = PAYLOAD_TYPE_RD;