Write a memory leak test for X.509 extensions (#3451)

* Bind a pair of mem functions.

* do the conditional correctly

* move to the right section

* Get the code basically working

* flake8

* say the correct incantation

* WOrkaround for hilarity

* Revert "WOrkaround for hilarity"

This reverts commit 37b9f3b4ed4063eef5add3bb5d5dd592a007d439.

* Swap out these functions for the originals

* nonsense for windows

* try writing this all out for windows

* Debugging utility

* Avoid this mess, don't dlopen anything

* Throw away this FFI entirely

* first pass at some x.509 memleak tests

* TODO and fix

* Get the tests to passing

* String formatting is nasty

* some fixes because rebasing

* fix for the name API, always use the OpenSSL backend
diff --git a/tests/hazmat/backends/test_openssl_memleak.py b/tests/hazmat/backends/test_openssl_memleak.py
index 8df5477..e4cbd0f 100644
--- a/tests/hazmat/backends/test_openssl_memleak.py
+++ b/tests/hazmat/backends/test_openssl_memleak.py
@@ -163,3 +163,25 @@
             def func():
                 raise ZeroDivisionError
             """))
+
+
+@skip_if_memtesting_not_supported()
+class TestOpenSSLMemoryLeaks(object):
+    @pytest.mark.parametrize("path", [
+        "x509/PKITS_data/certs/ValidcRLIssuerTest28EE.crt",
+    ])
+    def test_x509_extensions(self, path):
+        assert_no_memory_leaks(textwrap.dedent("""
+        def func(path):
+            from cryptography import x509
+            from cryptography.hazmat.backends.openssl import backend
+
+            import cryptography_vectors
+
+            with cryptography_vectors.open_vector_file(path, "rb") as f:
+                cert = x509.load_der_x509_certificate(
+                    f.read(), backend
+                )
+
+            cert.extensions
+        """), [path])