From b00af5f83acfe4c8fd76f1e5c13c1b0cd469daad Mon Sep 17 00:00:00 2001 From: knu Date: Thu, 26 Sep 2002 13:49:40 +0000 Subject: [PATCH] * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@2892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/digest/digest.c | 7 ++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6113d2864..746f483401 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Sep 26 22:44:21 2002 Akinori MUSHA + + * 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. + Wed Sep 25 23:51:29 2002 Nobuyoshi Nakada * dir.c (glob_helper): must not closedir() when exception raised diff --git a/ext/digest/digest.c b/ext/digest/digest.c index a431984750..7b4ea0f730 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; }