Fix issue detected by static analysis tool 46/258646/1
authorInHong Han <inhong1.han@samsung.com>
Fri, 21 May 2021 09:31:31 +0000 (18:31 +0900)
committerInHong Han <inhong1.han@samsung.com>
Fri, 21 May 2021 09:31:35 +0000 (18:31 +0900)
check_return: Calling fcntl(ret, 2, flag | 1) without checking return value.
This library function may fail and return an error code.

Change-Id: I19b98afd782d3a545c18548cfda1f7908d3ec94c

ism/src/scim_socket.cpp

index b580879..692ecd1 100644 (file)
@@ -759,7 +759,13 @@ public:
             m_address = addr;
             ret = SD_LISTEN_FDS_START + 0;
             int flag = fcntl (ret, F_GETFD, 0);
-            fcntl (ret, F_SETFD, flag|FD_CLOEXEC);
+            if (flag != -1)
+                flag = fcntl (ret, F_SETFD, flag|FD_CLOEXEC);
+
+            if (flag == -1) {
+                LOGW ("fcntl() failed");
+                return false;
+            }
             m_id = ret;
         } else {
             LOGW("No sd socket!!");