From 5f8df164716a43bd9e6c22dfd1f066bf96ccf273 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Sat, 18 Jul 2009 16:28:53 +0700 Subject: 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 file changed, 1 insertion(+) diff --git a/lib/util/util_file.c b/lib/util/util_file.c index 0275e78c54..7466004e5c 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); -- cgit