diff options
author | Matt Caswell <matt@openssl.org> | 2023-08-21 12:19:44 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2023-08-23 16:01:30 +0100 |
commit | 8ef63b6ff8301a0139c00df6c40173a63fd2db01 (patch) | |
tree | 4179e0f55810abfa1a35edcab86662d7e3213c90 /crypto | |
parent | 617cab094f0f0d4e71f8b9da5663be8ab06cba92 (diff) | |
download | openssl-8ef63b6ff8301a0139c00df6c40173a63fd2db01.tar.gz |
Fix a leak in ossl_encode_ctx_setup_for_pkey
Make sure we free the stack of names we allocated in an error path.
Found by the reproducible error patch in #21668
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/21796)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/encode_decode/encoder_pkey.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/encode_decode/encoder_pkey.c b/crypto/encode_decode/encoder_pkey.c index 6954343422..d482260102 100644 --- a/crypto/encode_decode/encoder_pkey.c +++ b/crypto/encode_decode/encoder_pkey.c @@ -284,8 +284,10 @@ static int ossl_encoder_ctx_setup_for_pkey(OSSL_ENCODER_CTX *ctx, end = sk_OPENSSL_CSTRING_num(encoder_data.names); if (end > 0) { encoder_data.id_names = OPENSSL_malloc(end * sizeof(int)); - if (encoder_data.id_names == NULL) + if (encoder_data.id_names == NULL) { + sk_OPENSSL_CSTRING_free(keymgmt_data.names); goto err; + } for (i = 0; i < end; ++i) { const char *name = sk_OPENSSL_CSTRING_value(keymgmt_data.names, i); |