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

Marshall Clow mclow.lists at gmail.com
Mon Jun 2 15:54:57 PDT 2014


On May 28, 2014, at 10:49 PM, David Majnemer <david.majnemer at gmail.com> wrote:

> 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.

LGTM - please commit.
[ open returns the smallest “non-negative integer” available ]

— Marshall






More information about the cfe-commits mailing list