normalperson / yhbt.net wrote:
> Bug #13595: rb_alloc_tmp_buffer2 broken when: elsize % sizeof(VALUE) == 0
> https://bugs.ruby-lang.org/issues/13595

Perhaps the following patch is what is needed:

--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1611,7 +1611,7 @@ static inline void *
 rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
 {
     size_t cnt = (size_t)count;
-    if (elsize % sizeof(VALUE) == 0) {
+    if (elsize == sizeof(VALUE)) {
 	if (RB_UNLIKELY(cnt > LONG_MAX / sizeof(VALUE))) {
 	    ruby_malloc_size_overflow(cnt, elsize);
 	}

...
     } /* else {...} */
     return rb_alloc_tmp_buffer_with_count(store, cnt * sizeof(VALUE), cnt);

Sorry; I am horrible at arithmetic.  Honestly I have panic
attacks whenever I try to do it.  Any help checking this
function would be greatly appreciated.  Thank you.

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>