From 92bdc5937e30f3cbee2e7076fb6364a3ff554b41 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 5 Mar 2020 11:14:24 +0100 Subject: [PATCH] utils: only move_fd() when fdopen() has been successful Signed-off-by: Christian Brauner --- src/lxc/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lxc/utils.c b/src/lxc/utils.c index 406a54c0a..8397d54ae 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -1724,9 +1724,10 @@ static int process_dead(/* takes */ int status_fd) return -1; /* transfer ownership of fd */ - f = fdopen(move_fd(dupfd), "re"); + f = fdopen(dupfd, "re"); if (!f) return -1; + move_fd(dupfd); ret = 0; while (getline(&line, &n, f) != -1) { -- 2.47.2