зеркало из https://github.com/github/ruby.git
[ruby/openssl] pkcs7: fix memory leak in error path of PKCS7.new and .read_smime
A follow-up to commit https://github.com/ruby/openssl/commit/27e11f2d1dcd and https://github.com/ruby/openssl/commit/07eceb7f6326. The PKCS7 object must be freed before raising an exception. https://github.com/ruby/openssl/commit/172eee4665
This commit is contained in:
Родитель
419fb2f3b9
Коммит
4e7e2e9e89
|
@ -167,8 +167,10 @@ ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg)
|
|||
BIO_free(in);
|
||||
if (!pkcs7)
|
||||
ossl_raise(ePKCS7Error, "Could not parse the PKCS7");
|
||||
if (!pkcs7->d.ptr)
|
||||
if (!pkcs7->d.ptr) {
|
||||
PKCS7_free(pkcs7);
|
||||
ossl_raise(ePKCS7Error, "No content in PKCS7");
|
||||
}
|
||||
|
||||
data = out ? ossl_membio2str(out) : Qnil;
|
||||
SetPKCS7(ret, pkcs7);
|
||||
|
@ -348,8 +350,10 @@ ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
|
|||
BIO_free(in);
|
||||
if (!p7)
|
||||
ossl_raise(rb_eArgError, "Could not parse the PKCS7");
|
||||
if (!p7->d.ptr)
|
||||
if (!p7->d.ptr) {
|
||||
PKCS7_free(p7);
|
||||
ossl_raise(rb_eArgError, "No content in PKCS7");
|
||||
}
|
||||
|
||||
RTYPEDDATA_DATA(self) = p7;
|
||||
PKCS7_free(p7_orig);
|
||||
|
|
Загрузка…
Ссылка в новой задаче