When EVP_CIPHER_param_to_asn1() fails, xalg->parameter was not freed,
leading to a memory leak. This patch adds proper cleanup for that case.
CLA: trivial
Signed-off-by: 77tiann <27392025k@gmail.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28131)
(cherry picked from commit
bda2473a44e4534c3c640ce89a0971874165c6df)
if (xalg->parameter == NULL)
goto err;
}
- if (EVP_CIPHER_param_to_asn1(ctx, xalg->parameter) <= 0)
+ if (EVP_CIPHER_param_to_asn1(ctx, xalg->parameter) <= 0) {
+ ASN1_TYPE_free(xalg->parameter);
+ xalg->parameter = NULL;
goto err;
+ }
}
/* Lets do the pub key stuff :-) */