From ba70f9b9a2da5e81dc9c9879cbd0f7dce6acedce Mon Sep 17 00:00:00 2001 From: "munkyu.im" Date: Thu, 26 Dec 2013 16:59:28 +0900 Subject: [PATCH] ecs: add checking error case returns when occur error case Change-Id: Ib2ad461e2bd99b73f3a22d72656a165d02bfa16c Signed-off-by: munkyu.im --- tizen/src/ecs/ecs.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/tizen/src/ecs/ecs.c b/tizen/src/ecs/ecs.c index 37f409b812..bcff82db2d 100644 --- a/tizen/src/ecs/ecs.c +++ b/tizen/src/ecs/ecs.c @@ -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 } -- 2.34.1