summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-14 15:39:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-14 15:39:46 +0000
commite1646e639a14f8430046dd424c1b745bea7f9840 (patch)
tree689ae31d573520360c9d957056883e5d611d1f50 /array.c
parenta8167d58b9c1b3cd3860e4e55cb98e7460337a00 (diff)
downloadbundler-e1646e639a14f8430046dd424c1b745bea7f9840.tar.gz
* array.c (ary_resize_capa): should not overwrite outside embedded
array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/array.c b/array.c
index 35023f3209..5a6ceebea9 100644
--- a/array.c
+++ b/array.c
@@ -163,7 +163,8 @@ ary_resize_capa(VALUE ary, long capacity)
else {
if (!ARY_EMBED_P(ary)) {
long len = RARRAY_LEN(ary);
- VALUE *ptr = RARRAY_PTR(ary);
+ VALUE *ptr = RARRAY_PTR(ary);
+ if (len > capacity) len = capacity;
MEMCPY(RARRAY(ary)->as.ary, ptr, VALUE, len);
FL_SET_EMBED(ary);
ARY_SET_LEN(ary, len);