From: Dongwoo Lee Date: Wed, 9 May 2018 06:21:34 +0000 (+0900) Subject: Fix wrong close for negative file descriptor X-Git-Tag: submit/trunk/20190927.044709~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ec0490922ecb0a824a8c705f7f0091f7eefb46d;p=tools%2Flthor.git Fix wrong close for negative file descriptor There is an issue which negative file descriptor can be attempt to close in static analysis tool result. This patch fixes to skip close on that case. Change-Id: Ic68803bc96ab6e3737d1bcc4779b8e3c58c7ef71 Signed-off-by: Seung-Woo Kim Signed-off-by: Dongwoo Lee --- diff --git a/libthor/thor_raw_file.c b/libthor/thor_raw_file.c index e357c68..fa02f28 100644 --- a/libthor/thor_raw_file.c +++ b/libthor/thor_raw_file.c @@ -100,7 +100,7 @@ int t_file_get_data_src(const char *path, struct thor_data_src **data) ret = open(path, O_RDONLY); if (ret < 0) - goto close_file; + goto free_data; fdata->fd = ret; @@ -138,6 +138,7 @@ int t_file_get_data_src(const char *path, struct thor_data_src **data) close_file: close(ret); +free_data: free(fdata); return -EINVAL; }