Skip to content

Commit cfd09ce

Browse files
committed
bug: better job at keeping a reference from CMS_SignerInfo to CMS_ContentInfo
1 parent add42a2 commit cfd09ce

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ext/openssl/ossl_cms.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,17 @@ ossl_cmsci_get_certificates(VALUE self)
294294
/*
295295
* CMS SignerInfo is not a first class object, but part of the
296296
* CMS ContentInfo. It can be wrapped in a ruby object, but it can
297-
* not be created or freed directly.
297+
* not be created or freed directly, so a reference to the CMS ContentInfo
298+
* is placed into the "cms" attribute.
298299
*/
299300
static VALUE
300-
ossl_cmssi_new(CMS_SignerInfo *cmssi)
301+
ossl_cmssi_new(VALUE ci, CMS_SignerInfo *cmssi)
301302
{
302303
VALUE obj;
303304

304305
obj = NewCMSsi(cCMSSignerInfo);
305306
SetCMSsi(obj, cmssi);
306-
rb_ivar_set(obj, rb_intern("cms"), cmssi);
307+
rb_ivar_set(ci, rb_intern("cms"), obj);
307308

308309
return obj;
309310
}
@@ -368,7 +369,7 @@ ossl_cmsci_get_signers(VALUE self)
368369
ary = rb_ary_new2(num);
369370
for (i=0; i<num; i++) {
370371
CMS_SignerInfo *si = sk_CMS_SignerInfo_value(sk, i);
371-
rb_ary_push(ary, ossl_cmssi_new(si));
372+
rb_ary_push(ary, ossl_cmssi_new(self, si));
372373
}
373374

374375
return ary;

0 commit comments

Comments
 (0)