[PATCH] [libc++] random_device fails if open returns zero

David Majnemer david.majnemer at gmail.com
Wed May 28 22:49:46 PDT 2014


random_device::random_device(const string&) initializes one if it's members
with the result of a call to open.

However, it 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140528/ff9a03a8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 1124 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140528/ff9a03a8/attachment.obj>


More information about the cfe-commits mailing list