aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-02-06 23:07:49 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-02-07 00:37:30 +1300
commitee5c49f0c5fa0f9091ef0bb17449f2d1bcce599d (patch)
tree33fd933d23dbee55cac2ebb082ace0154b6d6df6 /ext
parent90b6d2b283f0b817b17b90a7081b92aa213565cb (diff)
downloadruby-openssl-ee5c49f0c5fa0f9091ef0bb17449f2d1bcce599d.tar.gz
Improve string allocation.
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/ossl_ssl.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 432d404a..b1f8fd58 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -2408,14 +2408,14 @@ ossl_ssl_get_finished(VALUE self)
GetSSL(self, ssl);
char sizer[1];
- size_t len = SSL_get_finished(ssl, sizer, 1);
+ size_t len = SSL_get_finished(ssl, sizer, 0);
+
if(len == 0)
return Qnil;
- char* buf = ALLOCA_N(char, len+1);
- buf[len] = 0;
+ char* buf = ALLOCA_N(char, len);
SSL_get_finished(ssl, buf, len);
- return rb_str_new_cstr(buf);
+ return rb_str_new(buf, len);
}
/*
@@ -2433,14 +2433,14 @@ ossl_ssl_get_peer_finished(VALUE self)
GetSSL(self, ssl);
char sizer[1];
- size_t len = SSL_get_peer_finished(ssl, sizer, 1);
+ size_t len = SSL_get_peer_finished(ssl, sizer, 0);
+
if(len == 0)
return Qnil;
- char* buf = ALLOCA_N(char, len+1);
- buf[len] = 0;
+ char* buf = ALLOCA_N(char, len);
SSL_get_peer_finished(ssl, buf, len);
- return rb_str_new_cstr(buf);
+ return rb_str_new(buf, len);
}
/*