Revision
4507
Author
lsansonetti@apple.com
Date
2010-09-11 01:38:59 -0700 (Sat, 11 Sep 2010)

Log Message

fix a crasher in ASN1::Constructive#to_der

Modified Paths

Diff

Modified: MacRuby/trunk/ext/openssl/ossl_asn1.c (4506 => 4507)


--- MacRuby/trunk/ext/openssl/ossl_asn1.c	2010-09-11 00:36:29 UTC (rev 4506)
+++ MacRuby/trunk/ext/openssl/ossl_asn1.c	2010-09-11 08:38:59 UTC (rev 4507)
@@ -971,8 +971,9 @@
 
     seq_len = ASN1_object_size(1, RSTRING_LEN(value), tag);
     length = ASN1_object_size(1, seq_len, tn);
-    str = rb_str_new(0, length);
-    p = (unsigned char *)RSTRING_PTR(str);
+    str = rb_bstr_new();
+    rb_bstr_resize(str, length);
+    p = (unsigned char *)rb_bstr_bytes(str);
     if(tc == V_ASN1_UNIVERSAL)
 	ASN1_put_object(&p, 1, RSTRING_LEN(value), tn, tc);
     else{