crypto/rand: Fix a crash bug in RAND_enable_fork_unsafe_buffering.

Change-Id: Ifff59b1518f513c1be70e4e0d4ed3430741d0a5e
Reviewed-on: https://boringssl-review.googlesource.com/12860
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/rand/urandom.c b/crypto/rand/urandom.c
index 17d194c..14d2e8a 100644
--- a/crypto/rand/urandom.c
+++ b/crypto/rand/urandom.c
@@ -207,12 +207,12 @@
     abort();  // Already initialized
   }
 
-  if (urandom_fd == kHaveGetrandom) {
-    if (fd >= 0) {
+  if (fd >= 0) {
+    if (urandom_fd == kHaveGetrandom) {
       close(fd);
+    } else if (urandom_fd != fd) {
+      abort();  // Already initialized.
     }
-  } else if (urandom_fd != fd) {
-    abort();  // Already initialized.
   }
 }