open() can fail for various reasons, so check for valid 'fd' return

before calling fdopen.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2013-08-05 11:34:34 +01:00
parent 8270fc29f3
commit cc0bbacb89
1 changed files with 3 additions and 0 deletions

View File

@ -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;