Make sure the given EVP_PKEY is updated in the PEM_STRING_PKCS8INF case also.
authorRichard Levitte <levitte@openssl.org>
Thu, 26 Feb 2004 22:07:45 +0000 (22:07 +0000)
committerRichard Levitte <levitte@openssl.org>
Thu, 26 Feb 2004 22:07:45 +0000 (22:07 +0000)
PR: 833

crypto/pem/pem_pkey.c

index 92a55f536aebbbf958178273ad73e43fe3e0c1a7..d23adf302844c008e6b2cd7eea575f2734c2ba1b 100644 (file)
@@ -89,6 +89,10 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, vo
                p8inf=d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len);
                if(!p8inf) goto p8err;
                ret = EVP_PKCS82PKEY(p8inf);
+               if(x) {
+                       if(*x) EVP_PKEY_free((EVP_PKEY *)*x);
+                       *x = ret;
+               }
                PKCS8_PRIV_KEY_INFO_free(p8inf);
        } else if (strcmp(nm,PEM_STRING_PKCS8) == 0) {
                PKCS8_PRIV_KEY_INFO *p8inf;