Adding NULL check in CALEClientAddUuid 47/223447/1
authorsamanway <samanway@linux-samanway.sa.corp.samsungelectronics.net>
Wed, 22 Jan 2020 08:23:41 +0000 (13:53 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 30 Jan 2020 01:44:28 +0000 (10:44 +0900)
- NULL check was missed before passing string to strcmp()
- Hence, added NULL check

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/652
(cherry-picked from 2f6b188bc90dc306f98414189d30206eef38be4a)

Change-Id: Ia92a7a308dcb73999df84d48e67aad6e4d7be0e0
Signed-off-by: samanway-dey <samanway.dey@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c

index ebd8a30..856c42e 100755 (executable)
@@ -422,12 +422,17 @@ void CALEClientAddUuid(char* uuid, int uuid_type)
        if (g_manufactureDataCount == 0)
        {
            g_manufactureDataList = u_arraylist_create();
-          OIC_LOG(DEBUG, TAG, "List of manufacture data created");
+           if (!g_manufactureDataList)
+           {
+               OIC_LOG(ERROR, TAG, "List could not be created");
+               return;
+           }
+           OIC_LOG(DEBUG, TAG, "List of manufacture data created");
        }
        for (int i = 0; i < g_manufactureDataCount; i++)
        {
             char *str = u_arraylist_get(g_manufactureDataList, i);
-            if (!strcmp(uuid, str))
+            if (str && !strcmp(uuid, str))
             {
                 OIC_LOG(DEBUG, TAG, "UUID already set before");
                 return;
@@ -442,12 +447,18 @@ void CALEClientAddUuid(char* uuid, int uuid_type)
         if (g_serviceUuidCount == 0)
         {
             g_serviceUuidList = u_arraylist_create();
+            if (!g_serviceUuidList)
+            {
+                OIC_LOG(ERROR, TAG, "List could not be created");
+                return;
+            }
+
             OIC_LOG(DEBUG, TAG, "List of service uuid created");
         }
         for (int i = 0; i < g_serviceUuidCount; i++)
         {
             char *str = u_arraylist_get(g_serviceUuidList, i);
-            if (!strcmp(uuid, str))
+            if (str && !strcmp(uuid, str))
             {
                 OIC_LOG(DEBUG, TAG, "UUID already set before");
                 return;