From 9681d8791b4a85e3dc8acb1a7a5e4e7b2c4d1ac8 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 11 Oct 2006 08:01:25 +0000 Subject: [PATCH] * array.c (rb_ary_replace): should shift lfree pointer before calling xfree. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ array.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 885431d5a6..e0a9a03ce7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 11 16:57:46 2006 Yukihiro Matsumoto + + * array.c (rb_ary_replace): should shift lfree pointer before + calling xfree. + Wed Oct 11 15:07:42 2006 Akinori MUSHA * ext/digest/lib/digest/hmac.rb: Add digest/hmac, which implements diff --git a/array.c b/array.c index e488b556d2..d4957a95b3 100644 --- a/array.c +++ b/array.c @@ -2158,7 +2158,11 @@ rb_ary_replace(VALUE copy, VALUE orig) ARY_SET_NOEMBED(copy); } else { - xfree(RARRAY(copy)->as.heap.ptr); + VALUE *ptr = RARRAY(copy)->as.heap.ptr; + if (ARY_LFREE_P(copy)) { + ptr -= LFREE_SIZE(copy); + } + xfree(ptr); } RARRAY(copy)->as.heap.ptr = RARRAY(shared)->as.heap.ptr; RARRAY(copy)->as.heap.len = RARRAY(shared)->as.heap.len;