From cc0bbacb8971fdb7ece1b168e53cb2001fd15f47 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 5 Aug 2013 11:34:34 +0100 Subject: [PATCH] open() can fail for various reasons, so check for valid 'fd' return before calling fdopen. Signed-off-by: Chris Michael --- src/lib/eet/eet_lib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c index a8d507eb54..f85209aa98 100644 --- a/src/lib/eet/eet_lib.c +++ b/src/lib/eet/eet_lib.c @@ -351,6 +351,9 @@ eet_flush2(Eet_File *ef) /* opening for write - delete old copy of file right away */ unlink(ef->path); fd = open(ef->path, O_CREAT | O_TRUNC | O_RDWR | O_BINARY, S_IRUSR | S_IWUSR); + if (fd < 0) + return EET_ERROR_NOT_WRITABLE; + fp = fdopen(fd, "wb"); if (!fp) return EET_ERROR_NOT_WRITABLE;