After mkostemp() failed, umask() and free() might alter the errno
to another value. Not sure those calls really changes the errno
or not. But let's be more conservative.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
oldmode = umask(S_IRGRP|S_IWGRP|S_IXGRP|
S_IROTH|S_IWOTH|S_IXOTH);
fd = mkostemp(n, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
+ if (fd < 0)
+ fd = -errno;
umask(oldmode);
if (fd >= 0 && name)
else
free(n);
- return fd < 0 ? -errno : fd;
+ return fd;
}
/**