summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-01 15:03:09 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-01 15:03:09 +0000
commit3aa5496c9897b4aa284693da87bfa17e2e75aec8 (patch)
tree8b8ad99520b5a9bfb6fce64c49d5ddfd3405928f /struct.c
parenta9543d64f12e7003c143dca3084df6decc0485d9 (diff)
downloadbundler-3aa5496c9897b4aa284693da87bfa17e2e75aec8.tar.gz
* struct.c: accessing >10 member caused segmentation fault. [ruby-dev:26247]
* test/ruby/test_struct.rb: test it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/struct.c b/struct.c
index f0458a3520..17fc72b1e0 100644
--- a/struct.c
+++ b/struct.c
@@ -132,7 +132,9 @@ static VALUE rb_struct_ref7(obj) VALUE obj; {return RSTRUCT(obj)->ptr[7];}
static VALUE rb_struct_ref8(obj) VALUE obj; {return RSTRUCT(obj)->ptr[8];}
static VALUE rb_struct_ref9(obj) VALUE obj; {return RSTRUCT(obj)->ptr[9];}
-static VALUE (*ref_func[10])() = {
+#define N_REF_FUNC (sizeof(ref_func) / sizeof(VALUE (*)()))
+
+static VALUE (*ref_func[])() = {
rb_struct_ref0,
rb_struct_ref1,
rb_struct_ref2,
@@ -211,7 +213,7 @@ make_struct(name, members, klass)
for (i=0; i< RARRAY(members)->len; i++) {
ID id = SYM2ID(RARRAY(members)->ptr[i]);
if (rb_is_local_id(id) || rb_is_const_id(id)) {
- if (i<sizeof(ref_func)) {
+ if (i < N_REF_FUNC) {
rb_define_method_id(nstr, id, ref_func[i], 0);
}
else {