diff options
author | Matt Caswell <matt@openssl.org> | 2022-05-26 11:30:09 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2022-06-02 10:31:12 +0100 |
commit | da3193976380b8bd697a472025ff9f384cbca7af (patch) | |
tree | c61456fb724567cfa69b89e4ef2699bbd6f3433d | |
parent | 9ec9b968f93e4a8e7c90eb1e717f0d7cd4ab722d (diff) | |
download | openssl-new-da3193976380b8bd697a472025ff9f384cbca7af.tar.gz |
Fix another decoder mem leak on an error path
If pushing the decoder onto a stack fails then we should free the ref
we just created.
Found due to the error report here:
https://github.com/openssl/openssl/pull/18355#issuecomment-1138205688
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18411)
-rw-r--r-- | crypto/encode_decode/decoder_lib.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/encode_decode/decoder_lib.c b/crypto/encode_decode/decoder_lib.c index 9dcbab1077..8863c316d6 100644 --- a/crypto/encode_decode/decoder_lib.c +++ b/crypto/encode_decode/decoder_lib.c @@ -362,8 +362,9 @@ static void collect_all_decoders(OSSL_DECODER *decoder, void *arg) { STACK_OF(OSSL_DECODER) *skdecoders = arg; - if (OSSL_DECODER_up_ref(decoder)) - sk_OSSL_DECODER_push(skdecoders, decoder); + if (OSSL_DECODER_up_ref(decoder) + && !sk_OSSL_DECODER_push(skdecoders, decoder)) + OSSL_DECODER_free(decoder); } static void collect_extra_decoder(OSSL_DECODER *decoder, void *arg) |