Fix a compiler warning; also test get_extension_count a little more, and without relying on a pem blob
diff --git a/OpenSSL/crypto/x509.c b/OpenSSL/crypto/x509.c
index b8f2e83..a11fb8d 100644
--- a/OpenSSL/crypto/x509.c
+++ b/OpenSSL/crypto/x509.c
@@ -704,7 +704,7 @@
 static char crypto_X509_get_extension_doc[] = "\n\
 Get a specific extension of the certificate by index.\n\
 \n\
-@param index: The index of the extension to retrieve.
+@param index: The index of the extension to retrieve.\n\
 @return: The X509Extension object at the specified index.\n\
 ";
 
@@ -729,7 +729,7 @@
     extobj = PyObject_New(crypto_X509ExtensionObj, &crypto_X509Extension_Type);
     extobj->x509_extension = X509_EXTENSION_dup(ext);
 
-    return extobj;
+    return (PyObject*)extobj;
 }
 
 /* Copied from openssl/crypto/x509v3/v3_utl.c */
diff --git a/OpenSSL/test/test_crypto.py b/OpenSSL/test/test_crypto.py
index 8e96b92..6996550 100644
--- a/OpenSSL/test/test_crypto.py
+++ b/OpenSSL/test/test_crypto.py
@@ -1222,10 +1222,38 @@
     def test_extension_count(self):
         """
         L{X509.get_extension_count} returns the number of extensions that are
-        present in the certificate
+        present in the certificate.
         """
-        cert = load_certificate(FILETYPE_PEM, self.extpem)
-        self.assertEqual(cert.get_extension_count(),5)
+        pkey = load_privatekey(FILETYPE_PEM, client_key_pem)
+        def cert(extensions):
+            cert = X509()
+            cert.set_pubkey(pkey)
+            cert.get_subject().commonName = "Unit Tests"
+            cert.get_issuer().commonName = "Unit Tests"
+            when = b(datetime.now().strftime("%Y%m%d%H%M%SZ"))
+            cert.set_notBefore(when)
+            cert.set_notAfter(when)
+
+            cert.add_extensions(extensions)
+            return load_certificate(
+                FILETYPE_PEM, dump_certificate(FILETYPE_PEM, cert))
+
+        ca = X509Extension('basicConstraints', True, 'CA:FALSE')
+        key = X509Extension('keyUsage', True, 'digitalSignature')
+        subjectAltName = X509Extension(
+            'subjectAltName', True, 'DNS:example.com')
+
+        # Try a certificate with no extensions at all.
+        c = cert([])
+        self.assertEqual(c.get_extension_count(), 0)
+
+        # And a certificate with one
+        c = cert([ca])
+        self.assertEqual(c.get_extension_count(), 1)
+
+        # And a certificate with several
+        c = cert([ca, key, subjectAltName])
+        self.assertEqual(c.get_extension_count(), 3)
 
 
     def test_subjectaltname_of_type(self):