From 20c04820d16673901ade8b344aa745d1d3a8876d Mon Sep 17 00:00:00 2001 From: Petr Uzel Date: Mon, 14 Feb 2011 14:43:25 +0100 Subject: libuuid: do not use invalid file descriptor Signed-off-by: Petr Uzel --- shlibs/uuid/src/gen_uuid.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'shlibs') diff --git a/shlibs/uuid/src/gen_uuid.c b/shlibs/uuid/src/gen_uuid.c index a27d49c96..6e82a7b7c 100644 --- a/shlibs/uuid/src/gen_uuid.c +++ b/shlibs/uuid/src/gen_uuid.c @@ -324,10 +324,12 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low, state_fd = open("/var/lib/libuuid/clock.txt", O_RDWR|O_CREAT, 0660); (void) umask(save_umask); - state_f = fdopen(state_fd, "r+"); - if (!state_f) { - close(state_fd); - state_fd = -1; + if (state_fd != -1) { + state_f = fdopen(state_fd, "r+"); + if (!state_f) { + close(state_fd); + state_fd = -1; + } } } if (state_fd >= 0) { -- cgit v1.2.3-55-g7522