Revision
4508
Author
lsansonetti@apple.com
Date
2010-09-11 01:42:08 -0700 (Sat, 11 Sep 2010)

Log Message

fix a crasher in Netscape::SPKI#to_der

Modified Paths

Diff

Modified: MacRuby/trunk/ext/openssl/ossl_ns_spki.c (4507 => 4508)


--- MacRuby/trunk/ext/openssl/ossl_ns_spki.c	2010-09-11 08:38:59 UTC (rev 4507)
+++ MacRuby/trunk/ext/openssl/ossl_ns_spki.c	2010-09-11 08:42:08 UTC (rev 4508)
@@ -86,8 +86,9 @@
     GetSPKI(self, spki);
     if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0)
         ossl_raise(eX509CertError, NULL);
-    str = rb_str_new(0, len);
-    p = (unsigned char *)RSTRING_PTR(str);
+    str = rb_bstr_new();
+    rb_bstr_resize(str, len);
+    p = (unsigned char *)rb_bstr_bytes(str);
     if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
         ossl_raise(eX509CertError, NULL);
     ossl_str_adjust(str, p);