summaryrefslogtreecommitdiffstats
path: root/ext/digest
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-26 13:49:40 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-26 13:49:40 +0000
commitd29b165e2a2a228d21d2882f9978083ceb92f8d6 (patch)
tree27573a66e01d25bd3556346cb9aee6ff664a762b /ext/digest
parent54800209d6fb1fd7a0d648188ecfcb0ad36dd5b8 (diff)
downloadruby-d29b165e2a2a228d21d2882f9978083ceb92f8d6.tar.gz
ruby-d29b165e2a2a228d21d2882f9978083ceb92f8d6.tar.xz
ruby-d29b165e2a2a228d21d2882f9978083ceb92f8d6.zip
* ext/digest/digest.c (rb_digest_base_s_digest): Fix a double
free() bug mingled with allocation framework deployment. * ext/digest/digest.c (rb_digest_base_s_hexdigest): Get rid of redundant struct allocation. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest')
-rw-r--r--ext/digest/digest.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index a43198475..7b4ea0f73 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -105,7 +105,6 @@ rb_digest_base_s_digest(klass, str)
obj = rb_str_new(digest, len);
free(digest);
- free(pctx);
return obj;
}
@@ -121,11 +120,10 @@ rb_digest_base_s_hexdigest(klass, str)
unsigned char *hexdigest;
VALUE obj = rb_digest_base_alloc(klass);
- StringValue(str);
algo = get_digest_base_metadata(klass);
+ Data_Get_Struct(obj, void, pctx);
- pctx = xmalloc(algo->ctx_size);
- algo->init_func(pctx);
+ StringValue(str);
algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
len = algo->digest_len * 2;
@@ -136,7 +134,6 @@ rb_digest_base_s_hexdigest(klass, str)
obj = rb_str_new(hexdigest, len);
free(hexdigest);
- free(pctx);
return obj;
}