From e85bbc9e9c577efd4437a032463d4fd79da932b5 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 10 Sep 2015 10:57:12 -0400
Subject: [PATCH] random_bytes() can throw an exception in some cases, since PHP 7.0.0rc3

---
 program/lib/Roundcube/rcube_utils.php |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index 063296d..353347b 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -1101,7 +1101,11 @@
     {
         // Use PHP7 true random generator
         if (function_exists('random_bytes')) {
-            $random = @random_bytes($length);
+            // random_bytes() can throw an exception in some cases
+            try {
+                $random = @random_bytes($length);
+            }
+            catch (Exception $e) {}
         }
 
         if (!$random) {

--
Gitblit v1.9.1