summaryrefslogtreecommitdiffstats
path: root/libcxx/src
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-06-03 02:21:37 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-06-03 02:21:37 +0000
commit1e9592a9c71ed87c806946ad2cccc1bcb472324d (patch)
tree847dbc2f903eda47bd45c8abcce95ed631da1ab8 /libcxx/src
parentcf2048bbb3c3340e676fa166b2afd68e9ebf4e8d (diff)
downloadbcm5719-llvm-1e9592a9c71ed87c806946ad2cccc1bcb472324d.tar.gz
bcm5719-llvm-1e9592a9c71ed87c806946ad2cccc1bcb472324d.zip
[libc++] random_device fails if open returns zero
random_device::random_device(const string&) wrongly assumes that open can only validly return a file descriptor greater than zero. This results in random_device believing that it didn't successfully open the device causing it to throw in it's constructor, this ends up leaking a file descriptor. The fix is simple, don't error on file descriptors which are zero. llvm-svn: 210060
Diffstat (limited to 'libcxx/src')
-rw-r--r--libcxx/src/random.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libcxx/src/random.cpp b/libcxx/src/random.cpp
index bd24f2e50c1..21e21689a87 100644
--- a/libcxx/src/random.cpp
+++ b/libcxx/src/random.cpp
@@ -49,7 +49,7 @@ random_device::operator()()
random_device::random_device(const string& __token)
: __f_(open(__token.c_str(), O_RDONLY))
{
- if (__f_ <= 0)
+ if (__f_ < 0)
__throw_system_error(errno, ("random_device failed to open " + __token).c_str());
}
OpenPOWER on IntegriCloud