Add guard for allocations failure of X509 objects (#507)

diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index c37f20b..c31a9d2 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -982,10 +982,9 @@
     """
     An X.509 certificate.
     """
-
     def __init__(self):
-        # TODO Allocation failure?  And why not __new__ instead of __init__?
         x509 = _lib.X509_new()
+        _openssl_assert(x509 != _ffi.NULL)
         self._x509 = _ffi.gc(x509, _lib.X509_free)
 
     def set_version(self, version):