]> granicus.if.org Git - curl/commitdiff
Evan Jordan's fix for a memory leak. Bug report 650989.
authorDaniel Stenberg <daniel@haxx.se>
Fri, 13 Dec 2002 14:08:49 +0000 (14:08 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 13 Dec 2002 14:08:49 +0000 (14:08 +0000)
lib/ssluse.c

index 5239cafd46965db70a5f9da74c4e54ab6b031724..a79a9a71bcb0f402e070163ef6ec8fbc79752a8a 100644 (file)
@@ -325,10 +325,15 @@ int cert_stuff(struct connectdata *conn,
 
     ssl=SSL_new(conn->ssl.ctx);
     x509=SSL_get_certificate(ssl);
-    
-    if (x509 != NULL)
-      EVP_PKEY_copy_parameters(X509_get_pubkey(x509),
-                              SSL_get_privatekey(ssl));
+
+    /* This version was provided by Evan Jordan and is supposed to not
+       leak memory as the previous version: */
+    if (x509 != NULL) {
+      EVP_PKEY *pktmp = X509_get_pubkey(x509);
+      EVP_PKEY_copy_parameters(pktmp,SSL_get_privatekey(ssl));
+      EVP_PKEY_free(pktmp);
+    }
+
     SSL_free(ssl);
 
     /* If we are using DSA, we can copy the parameters from