diff options
author | Technorama team <oss-ruby@technorama.net> | 2004-06-26 21:08:44 +0000 |
---|---|---|
committer | Technorama team <oss-ruby@technorama.net> | 2004-06-26 21:08:44 +0000 |
commit | baf1fbde422c8e7c37379c2e80c4b09962019aec (patch) | |
tree | 6ecc87461166be81d5092dd461f149db99c7a0fd | |
parent | 8be43e8509ceec538a5f8d99f64b1559724f7cc4 (diff) | |
download | ruby-openssl-history-baf1fbde422c8e7c37379c2e80c4b09962019aec.tar.gz |
fix memory leak with .reset
-rw-r--r-- | ossl_digest.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ossl_digest.c b/ossl_digest.c index 695507c..069340d 100644 --- a/ossl_digest.c +++ b/ossl_digest.c @@ -68,7 +68,7 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self) if (!md) { ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name); } - EVP_DigestInit(ctx, md); + EVP_DigestInit_ex(ctx, md, NULL); if (!NIL_P(data)) return ossl_digest_update(self, data); return self; @@ -98,7 +98,7 @@ ossl_digest_reset(VALUE self) EVP_MD_CTX *ctx; GetDigest(self, ctx); - EVP_DigestInit(ctx, EVP_MD_CTX_md(ctx)); + EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL); return self; } @@ -124,9 +124,10 @@ digest_final(EVP_MD_CTX *ctx, char **buf, int *buf_len) ossl_raise(eDigestError, NULL); } if (!(*buf = OPENSSL_malloc(EVP_MD_CTX_size(&final)))) { + EVP_MD_CTX_cleanup(&final); ossl_raise(eDigestError, "Cannot allocate mem for digest"); } - EVP_DigestFinal(&final, *buf, buf_len); + EVP_DigestFinal_ex(&final, *buf, buf_len); EVP_MD_CTX_cleanup(&final); } |