Revision: 4373 http://trac.macosforge.org/projects/ruby/changeset/4373 Author: lsansonetti@apple.com Date: 2010-07-23 18:07:02 -0700 (Fri, 23 Jul 2010) Log Message: ----------- fix crashes in #update and #final Modified Paths: -------------- MacRuby/trunk/ext/openssl/ossl_cipher.c Modified: MacRuby/trunk/ext/openssl/ossl_cipher.c =================================================================== --- MacRuby/trunk/ext/openssl/ossl_cipher.c 2010-07-22 21:44:23 UTC (rev 4372) +++ MacRuby/trunk/ext/openssl/ossl_cipher.c 2010-07-24 01:07:02 UTC (rev 4373) @@ -323,9 +323,11 @@ out_len = in_len+EVP_CIPHER_CTX_block_size(ctx); if (NIL_P(str)) { - str = rb_str_new(0, out_len); + str = rb_bstr_new(); + rb_bstr_resize(str, out_len); } else { StringValue(str); + str = rb_str_bstr(str); rb_str_resize(str, out_len); } @@ -353,7 +355,8 @@ VALUE str; GetCipher(self, ctx); - str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx)); + str = rb_bstr_new(); + rb_bstr_resize(str, EVP_CIPHER_CTX_block_size(ctx)); if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len)) ossl_raise(eCipherError, NULL); assert(out_len <= RSTRING_LEN(str));