Fix Prevent issue
authorKarol Pawlowski <k.pawlowski@samsung.com>
Mon, 23 Sep 2013 07:01:08 +0000 (09:01 +0200)
committerHoseon LEE <hoseon46.lee@samsung.com>
Sun, 29 Sep 2013 08:09:59 +0000 (17:09 +0900)
[Issue#]   CID: 15851
[Problem]  Static analysis fails
[Cause]    N/A
[Solution] Refactored proces_pool_fd_handler method

[Verification] Build wrt repository.
Launch widget with wrt-client -l and wrt-launcher -s

Change-Id: Ib354c50a6734ef90fe6c0e0c40dad1a8c2b6b352

src/wrt-client/wrt-client.cpp

index 1f62eea..406db78 100644 (file)
@@ -910,17 +910,17 @@ static Eina_Bool proces_pool_fd_handler(void* /*data*/, Ecore_Fd_Handler *handle
 {
     int fd = ecore_main_fd_handler_fd_get(handler);
 
+    if (fd == -1)
+    {
+        LogDebug("ECORE_FD_GET");
+        exit(-1);
+    }
+
     if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
     {
         LogDebug("ECORE_FD_ERROR");
-
-        if (fd != -1)
-        {
-            close(fd);
-        }
-
+        close(fd);
         exit(-1);
-        return ECORE_CALLBACK_CANCEL;
     }
 
     if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
@@ -931,28 +931,21 @@ static Eina_Bool proces_pool_fd_handler(void* /*data*/, Ecore_Fd_Handler *handle
             memset(pkt, 0, AUL_SOCK_MAXBUFF);
 
             int recv_ret = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
-
-            if (fd != -1)
-            {
-                close(fd);
-            }
+            close(fd);
 
             if (recv_ret == -1)
             {
                 LogDebug("recv error!");
+                free(pkt);
                 exit(-1);
             }
-            LogDebug("recv_ret : " << recv_ret << ", pkt->len : " << pkt->len);
 
+            LogDebug("recv_ret : " << recv_ret << ", pkt->len : " << pkt->len);
             ecore_main_fd_handler_del(handler);
-
             process_pool_launchpad_main_loop(pkt, app_argv[0], &app_argc, &app_argv);
-
             free(pkt);
         }
-
         ecore_main_loop_quit();
-        return ECORE_CALLBACK_CANCEL;
     }
 
     return ECORE_CALLBACK_CANCEL;