Skip to content

Commit

Permalink
Merge pull request #106 from patrickbkr/fix-doubleclose-segfault
Browse files Browse the repository at this point in the history
Fix segfaults when double closing
  • Loading branch information
ugexe authored Feb 17, 2024
2 parents e0eafaf + e46ef8a commit 0c66e87
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/OpenSSL.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,26 @@ method check-private-key {
}

method shutdown {
OpenSSL::SSL::SSL_shutdown($.ssl);
with $!ssl {
OpenSSL::SSL::SSL_shutdown($!ssl);
}
}

method ctx-free {
OpenSSL::Ctx::SSL_CTX_free($!ctx);
with $!ctx {
OpenSSL::Ctx::SSL_CTX_free($!ctx);
$!ctx = Nil;
}
}

method ssl-free {
OpenSSL::SSL::SSL_free($!ssl);
if $.using-bio {
# $.internal-bio is freed by the SSL_free call
OpenSSL::Bio::BIO_free($.net-bio);
with $!ssl {
OpenSSL::SSL::SSL_free($!ssl);
if $.using-bio {
# $.internal-bio is freed by the SSL_free call
OpenSSL::Bio::BIO_free($.net-bio);
}
$!ssl = Nil;
}
}

Expand Down

0 comments on commit 0c66e87

Please sign in to comment.