Skip to content

Commit

Permalink
digest: load digest library using Kernel#require
Browse files Browse the repository at this point in the history
The digest library is a default gem now, too. Therefore we can't simply
use rb_require() to load it, but we should use Kernel#require instead.

This change is based on the suggestion by David Rodríguez in
ruby/digest@1617261#commitcomment-57778397
  • Loading branch information
rhenium committed Oct 12, 2021
1 parent 6880dba commit 157f807
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ext/openssl/ossl_digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ ossl_digest_block_length(VALUE self)
void
Init_ossl_digest(void)
{
rb_require("digest");

#if 0
mOSSL = rb_define_module("OpenSSL");
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
Expand Down Expand Up @@ -433,6 +431,12 @@ Init_ossl_digest(void)
* digest2 = sha256.digest(data2)
*
*/

/*
* Digest::Class is defined by the digest library. rb_require() cannot be
* used here because it bypasses RubyGems.
*/
rb_funcall(Qnil, rb_intern_const("require"), 1, rb_str_new_cstr("digest"));
cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class"));
/* Document-class: OpenSSL::Digest::DigestError
*
Expand Down

0 comments on commit 157f807

Please sign in to comment.