lib/util/util_file.c(file_save): fixed file descriptor leak when read(2) fails.
authorSlava Semushin <php-coder@altlinux.ru>
Sat, 18 Jul 2009 09:28:53 +0000 (16:28 +0700)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 19 Jul 2009 14:00:39 +0000 (16:00 +0200)
Found by cppcheck:
[./lib/util/util_file.c:383]: (error) Resource leak: fd

lib/util/util_file.c

index 0275e78c54fc89f3a69d2539c82874ea1ce10878..7466004e5ce07f175608202d797d23d94f2f2274 100644 (file)
@@ -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);