ecs: add checking error case 71/14171/1
authormunkyu.im <munkyu.im@samsung.com>
Thu, 26 Dec 2013 07:59:28 +0000 (16:59 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Thu, 26 Dec 2013 07:59:28 +0000 (16:59 +0900)
returns when occur error case

Change-Id: Ib2ad461e2bd99b73f3a22d72656a165d02bfa16c
Signed-off-by: munkyu.im <munkyu.im@samsung.com>
tizen/src/ecs/ecs.c

index 37f409b81277285eefaad8d89a5b3023c46c5637..bcff82db2df8a595b5afa8dae8ae526b7d2fea22 100644 (file)
@@ -170,16 +170,42 @@ static inline void start_logging(void) {
 
     stdout[0] = flog[0];
     stderr[0] = flog[0];
+
+    g_free(path);
 #else
     log_fd = open("/dev/null", O_RDONLY);
-    dup2(log_fd, 0);
+    if(log_fd < 0) {
+        fprintf(stderr, "failed to open() /dev/null\n");
+        return;
+    }
+    if(dup2(log_fd, 0) < 0) {
+        fprintf(stderr, "failed to dup2(log_fd, 0)\n");
+        return;
+    }
 
     log_fd = creat(path, 0640);
     if (log_fd < 0) {
         log_fd = open("/dev/null", O_WRONLY);
+        if(log_fd < 0) {
+            fprintf(stderr, "failed to open(/dev/null, O_WRONLY)\n");
+            g_free(path);
+            return;
+        }
     }
-    dup2(log_fd, 1);
-    dup2(log_fd, 2);
+
+    if(dup2(log_fd, 1) < 0) {
+        fprintf(stderr, "failed to dup2(log_fd, 1)\n");
+        g_free(path);
+        return;
+    }
+
+    if(dup2(log_fd, 2) < 0) {
+        fprintf(stderr, "failed to dup2(log_fd, 2)\n");
+        g_free(path);
+        return;
+    }
+
+    g_free(path);
 #endif
 }