summaryrefslogtreecommitdiff
path: root/ext/openssl
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-21 05:40:23 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-21 05:40:23 +0000
commita8fee4c9bbec29acf15c6f69501bb726ce8da071 (patch)
tree744a638f9101badce422368379f471b0aebb561c /ext/openssl
parent3ded769c39c95caec0ee8d80117e69bbd0bca439 (diff)
* ext/openssl/ossl_asn1.c (ossl_asn1_traverse, ossl_asn1_decode):
use rb_str_new4 to avoid SEGV. fix [ruby-dev:25261] * test/openssl/test_asn1.rb: add tests for OpenSSL::ASN1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/ossl_asn1.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
index abea6f5f0c..8b71b8cb61 100644
--- a/ext/openssl/ossl_asn1.c
+++ b/ext/openssl/ossl_asn1.c
@@ -815,12 +815,11 @@ ossl_asn1_traverse(VALUE self, VALUE obj)
long offset = 0;
obj = ossl_to_der_if_possible(obj);
- StringValue(obj);
- obj = rb_str_new4(obj);
+ obj = rb_str_new4(StringValue(obj));
p = RSTRING(obj)->ptr;
ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 0, 1);
- return obj;
+ return Qnil;
}
static VALUE
@@ -831,8 +830,7 @@ ossl_asn1_decode(VALUE self, VALUE obj)
long offset = 0;
obj = ossl_to_der_if_possible(obj);
- StringValue(obj);
- obj = rb_str_new4(obj);
+ obj = rb_str_new4(StringValue(obj));
p = RSTRING(obj)->ptr;
ary = ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 1, 0);
ret = rb_ary_entry(ary, 0);