From 07e89bde4693fa6b8da4c152f1cf91686d1823f1 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 23 Dec 2024 10:55:49 -0500 Subject: [PATCH] Fix MEMMOVE in rb_darray_insert Ruby's MEMMOVE takes in the element data type for the third argument, not the size of the element. What this did was do sizeof(sizeof( ... )) which always returned sizeof(size_t). --- darray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/darray.h b/darray.h index baaf350f56..8c4a9d40af 100644 --- a/darray.h +++ b/darray.h @@ -58,7 +58,7 @@ MEMMOVE( \ rb_darray_ref(*(ptr_to_ary), idx + 1), \ rb_darray_ref(*(ptr_to_ary), idx), \ - sizeof((*(ptr_to_ary))->data[0]), \ + (*(ptr_to_ary))->data[0], \ rb_darray_size(*(ptr_to_ary)) - idx); \ rb_darray_set(*(ptr_to_ary), idx, element); \ (*(ptr_to_ary))->meta.size++; \