[IOT-2092] Check null pointer before dereference
authorol.beketov <ol.beketov@samsung.com>
Thu, 4 May 2017 13:42:08 +0000 (16:42 +0300)
committerRandeep Singh <randeep.s@samsung.com>
Fri, 12 May 2017 11:20:19 +0000 (11:20 +0000)
Change-Id: Ib8032c41e8910087be5c5b30fee9a7b4a3992f01
Signed-off-by: ol.beketov <ol.beketov@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19623
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Andrii Shtompel <a.shtompel@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
plugins/zigbee_wrapper/telegesis_wrapper/src/telegesis_socket.c

index 877cf06..a42926d 100644 (file)
@@ -475,11 +475,10 @@ TWResultCode TWRetrieveEUI(PIPlugin_Zigbee * plugin, TWSock * twSock)
     entry = readEntry(twSock->fd);
     if(!entry)
     {
-        result = TWReleaseMutex(&twSock->mutex);
-        if(result != TW_RESULT_OK)
-        {
-            goto exit;
-        }
+        TWReleaseMutex(&twSock->mutex);
+        // in case entry is NULL, further processing will cause crash or UB
+        result = TW_RESULT_ERROR;
+        goto exit;
     }
     twSock->eui = (char *) OICMalloc(strlen(entry->lines[0].line)+1);
     if(!twSock->eui)