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)
{
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)