Fix a mem leak in CMS
authorMatt Caswell <matt@openssl.org>
Tue, 1 May 2018 08:29:17 +0000 (09:29 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 8 May 2018 07:49:03 +0000 (08:49 +0100)
commit2ddfe60be50bfeebd64e01b123fd7176e7226c87
tree2b992cbd4f5458aeeb9200a5a2ebd4b9f01974df
parent414d19d0341407b211c64729df37889e2c572e12
Fix a mem leak in CMS

The function CMS_RecipientInfo_set0_pkey() is a "set0" and therefore
memory management passes to OpenSSL. If the same function is called again
then we should ensure that any previous value that was set is freed first
before we set it again.

Fixes #5052

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6142)

(cherry picked from commit 3d551b20df1acd01f80d3ae00d37177e0fdf344a)
crypto/cms/cms_env.c
crypto/cms/cms_smime.c