Skip to content

Commit

Permalink
#name raises an exception with unloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
QWYNG committed Jun 14, 2023
1 parent 602a411 commit af6c2e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
12 changes: 4 additions & 8 deletions ext/openssl/ossl_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,16 @@ ossl_provider_unload(VALUE self)
* call-seq:
* provider.name -> string
*
* Get the name of the provider.
* Get the name of this provider.
*
* if this provider is already unloaded, it returns nil
* l = OpenSSL::Provider.load("legacy")
* l.name #=> "legacy"
* l.unload
* l.name #=> nil
* if this provider is already unloaded, it raises OpenSSL::Provider::ProviderError
*/
static VALUE
ossl_provider_get_name(VALUE self)
{
OSSL_PROVIDER *prov;
if (RTYPEDDATA_DATA(self) == NULL ) {
return Qnil;
if (RTYPEDDATA_DATA(self) == NULL) {
ossl_raise(eProviderError, "Provider already unloaded.");
}
GetProvider(self, prov);

Expand Down
3 changes: 2 additions & 1 deletion test/openssl/test_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ def test_openssl_provider_names
end;
end

def test_openssl_provider_unload_twice
def test_unloaded_openssl_provider
with_openssl <<-'end;'
default_provider = OpenSSL::Provider.load("default")
assert_equal(true, default_provider.unload)
assert_raise(OpenSSL::Provider::ProviderError) { default_provider.name }
assert_raise(OpenSSL::Provider::ProviderError) { default_provider.unload }
end;
end
Expand Down

0 comments on commit af6c2e6

Please sign in to comment.