diff options
author | Matt Caswell <matt@openssl.org> | 2022-05-26 11:09:58 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2022-06-02 10:31:12 +0100 |
commit | 9ec9b968f93e4a8e7c90eb1e717f0d7cd4ab722d (patch) | |
tree | 123364a142ab5d0dd754073bb1d74d1c51681910 | |
parent | 2cba2e160d5b028e4a777e8038744a8bc4280629 (diff) | |
download | openssl-9ec9b968f93e4a8e7c90eb1e717f0d7cd4ab722d.tar.gz |
Fix a decoder mem leak on an error path
If an error condition occurs then the the decoder that was up-refed in
ossl_decoder_instance_new can be leaked.
Found due to the error report here:
https://github.com/openssl/openssl/pull/18355#issuecomment-1138205688
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/18410)
-rw-r--r-- | crypto/encode_decode/decoder_lib.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c index 5dd75ae5f2..9dcbab1077 100644 --- a/crypto/encode_decode/decoder_lib.c +++ b/crypto/encode_decode/decoder_lib.c @@ -228,10 +228,6 @@ OSSL_DECODER_INSTANCE *ossl_decoder_instance_new(OSSL_DECODER *decoder, ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_MALLOC_FAILURE); return 0; } - if (!OSSL_DECODER_up_ref(decoder)) { - ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_INTERNAL_ERROR); - goto err; - } prov = OSSL_DECODER_get0_provider(decoder); libctx = ossl_provider_libctx(prov); @@ -263,6 +259,10 @@ OSSL_DECODER_INSTANCE *ossl_decoder_instance_new(OSSL_DECODER *decoder, = ossl_property_get_string_value(libctx, prop); } + if (!OSSL_DECODER_up_ref(decoder)) { + ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_INTERNAL_ERROR); + goto err; + } decoder_inst->decoder = decoder; decoder_inst->decoderctx = decoderctx; return decoder_inst; |