[btls] Fix a small memleak in btls-x509-lookup.c (#5065)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 19 Jun 2017 10:54:32 +0000 (12:54 +0200)
committerGitHub <noreply@github.com>
Mon, 19 Jun 2017 10:54:32 +0000 (12:54 +0200)
Noticed this while looking at the Clang Analysis Report[1] as the
only memory leak in the report and thought why not fix it :)

[1] https://jenkins.mono-project.com/job/test-mono-mainline-staticanalysis/Clang_Analysis_Report/

mono/btls/btls-x509-lookup.c

index 567d19c237aef062c42788196b7b6aed81941f1c..9e7dbee7702035c34b13a2110976531166bd2aad 100644 (file)
@@ -48,8 +48,10 @@ mono_btls_x509_lookup_new (MonoBtlsX509Store *store, MonoBtlsX509LookupType type
                return NULL;
 
        store_lookup = X509_STORE_add_lookup (mono_btls_x509_store_peek_store (store), method);
-       if (!store_lookup)
+       if (!store_lookup) {
+               OPENSSL_free (lookup);
                return NULL;
+       }
 
        memset (lookup, 0, sizeof(MonoBtlsX509Lookup));
        // The X509_STORE owns the X509_LOOKUP.