diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-05 23:37:40 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-05 23:37:40 +0200 |
commit | fdf14ae2e653f275c085329b183373e1fb062693 (patch) | |
tree | af64aedb51e30bda270721bf37729bcb1f4cb567 /libc/misc | |
parent | a76558a92e21643a628c3c6a8cd22816634b1749 (diff) |
do not save/restore errno around free() calls
In any non-buggy program free() does not fail.
And when it fails in a buggy program, the failure
is usually fatal (heap corruption and segfault).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libc/misc')
-rw-r--r-- | libc/misc/dirent/opendir.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c index 70b30658e..672ef15a4 100644 --- a/libc/misc/dirent/opendir.c +++ b/libc/misc/dirent/opendir.c @@ -87,16 +87,17 @@ DIR *opendir(const char *name) fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY|O_CLOEXEC); if (fd < 0) return NULL; - /* Note: we should check to make sure that between the stat() and open() * call, 'name' didnt change on us, but that's only if O_DIRECTORY isnt * defined and since Linux has supported it for like ever, i'm not going * to worry about it right now (if ever). */ + if (fstat(fd, &statbuf) < 0) { - int saved_errno; - saved_errno = errno; + // this close() never fails + //int saved_errno; + //saved_errno = errno; close(fd); - __set_errno(saved_errno); + //__set_errno(saved_errno); return NULL; } |