Fixed dangling imemo_tmpbuf
The count of rb_alloc_tmp_buffer_with_count is the allocation size counted in VALUE size but not in the requested element size. Co-authored-by: Yusuke Endoh <mame@ruby-lang.org> Co-authored-by: Koichi Sasada <ko1@atdot.net>
This commit is contained in:
parent
4b6fd8329b
commit
f690eb34e2
@ -250,8 +250,9 @@ rbimpl_size_mul_or_raise(size_t x, size_t y)
|
|||||||
static inline void *
|
static inline void *
|
||||||
rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
|
rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
|
||||||
{
|
{
|
||||||
return rb_alloc_tmp_buffer_with_count(
|
const size_t total_size = rbimpl_size_mul_or_raise(count, elsize);
|
||||||
store, rbimpl_size_mul_or_raise(count, elsize), count);
|
const size_t cnt = (total_size + sizeof(VALUE) - 1) / sizeof(VALUE);
|
||||||
|
return rb_alloc_tmp_buffer_with_count(store, total_size, cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user