Skip to content

Commit

Permalink
free up memory as recommended in the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mhorbul committed Feb 13, 2017
1 parent 3ceed7c commit 1fd6081
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package openssl
// #include <openssl/conf.h>
// #include <openssl/engine.h>
// #include <openssl/rsa.h>
// #include <openssl/crypto.h>
//
// int EVP_SignInit_not_a_macro(EVP_MD_CTX *ctx, const EVP_MD *type) {
// return EVP_SignInit(ctx, type);
Expand Down Expand Up @@ -209,6 +210,8 @@ func (key *pKey) GetModulus() ([]byte, error) {
if m == nil {
return nil, errors.New("failed to find RSA key modulus")
}
defer C.CRYPTO_free(unsafe.Pointer(m))

return ([]byte)(C.GoString(m)), nil
}

Expand Down

0 comments on commit 1fd6081

Please sign in to comment.