summaryrefslogtreecommitdiff
path: root/Python/random.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-16 18:27:44 +0200
committerVictor Stinner <victor.stinner@gmail.com>2016-08-16 18:27:44 +0200
commitc0eea49e2df42814569b3e7fdc089021dfed668a (patch)
tree446498f826b29c56042f012940bf3f28c25768d8 /Python/random.c
parentddceb622b9c351bd2ac681a46f628e4d93f5e6c3 (diff)
downloadcpython-c0eea49e2df42814569b3e7fdc089021dfed668a.tar.gz
Issue #27776: dev_urandom(raise=0) now closes the file descriptor on error
Diffstat (limited to 'Python/random.c')
-rw-r--r--Python/random.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Python/random.c b/Python/random.c
index 511070add0..6fdce64bca 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -331,6 +331,7 @@ dev_urandom(char *buffer, Py_ssize_t size, int raise)
if (n <= 0) {
/* stop on error or if read(size) returned 0 */
+ close(fd);
return -1;
}