[CRIU] [PATCH 10/18] files: don't leak a file descriptor

Andrei Vagin avagin at openvz.org
Thu Nov 9 22:21:04 MSK 2017


From: Andrei Vagin <avagin at virtuozzo.com>

CID 181293 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable gfd going out of scope leaks the handle.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/files-reg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/criu/files-reg.c b/criu/files-reg.c
index 9f5462cd0..16652ce3b 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -305,6 +305,7 @@ static int mkreg_ghost(char *path, GhostFileEntry *gfe, struct cr_img *img)
 	if (gfe->chunks) {
 		if (!gfe->has_size) {
 			pr_err("Corrupted ghost image -> no size\n");
+			close(gfd);
 			return -1;
 		}
 
-- 
2.13.6



More information about the CRIU mailing list