From cd0a798c199db6e9bb3025d93263d9141ec0aa34 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Sat, 18 Jul 2009 16:28:53 +0700 Subject: [PATCH] lib/util/util_file.c(file_save): fixed file descriptor leak when read(2) fails. Found by cppcheck: [./lib/util/util_file.c:383]: (error) Resource leak: fd --- lib/util/util_file.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/lib/util/util_file.c b/lib/util/util_file.c index 0275e78..7466004 100644 --- a/lib/util/util_file.c +++ b/lib/util/util_file.c @@ -380,6 +380,7 @@ _PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length) return false; } if (write(fd, packet, length) != (size_t)length) { + close(fd); return false; } close(fd); -- 1.6.3.3