From 6766fcb90557312be9572f63aff07d57df31f640 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 11 May 2025 20:11:56 +0900 Subject: [PATCH] class.c (mt_rehash): Fix mrb_calloc argument order Since mrb_calloc() (along with mrb_calloc) takes two arguments: nmemb which is number of array elements, and size which is size of the array. Of course, revsersing does not change the behavior, but we'd like to respect the original design intention of calloc(3). --- src/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class.c b/src/class.c index 1031a5313..814bfbf81 100644 --- a/src/class.c +++ b/src/class.c @@ -78,7 +78,7 @@ mt_rehash(mrb_state *mrb, mt_tbl *t) int new_alloc = old_alloc > 0 ? old_alloc << 1 : 8; union mt_ptr *old_ptr = t->ptr; - t->ptr = (union mt_ptr*)mrb_calloc(mrb, sizeof(union mt_ptr)+sizeof(mrb_sym), new_alloc); + t->ptr = (union mt_ptr*)mrb_calloc(mrb, new_alloc, sizeof(union mt_ptr)+sizeof(mrb_sym)); t->alloc = new_alloc; t->size = 0; if (old_alloc == 0) return;