Skip array embedding if MRB_NO_BOXING and MRB_32BIT; fix #4382

On some platforms, `sizeof(mrb_value) > sizeof(void*)*3`, which makes
`MRB_ARY_EMBED_LEN_MAX` zero. And zero sized array cause compile errors.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-08-12 21:47:23 +09:00
parent a93ef815be
commit 8813ebec07
4 changed files with 29 additions and 5 deletions
+8 -2
View File
@@ -1123,8 +1123,14 @@ mrb_ary_clear(mrb_state *mrb, mrb_value self)
else if (!ARY_EMBED_P(a)){
mrb_free(mrb, a->as.heap.ptr);
}
ARY_SET_EMBED_LEN(a, 0);
if (MRB_ARY_EMBED_LEN_MAX > 0) {
ARY_SET_EMBED_LEN(a, 0);
}
else {
a->as.heap.ptr = NULL;
a->as.heap.aux.capa = 0;
ARY_SET_LEN(a, 0);
}
return self;
}
+1
View File
@@ -6,6 +6,7 @@
static inline void
value_move(mrb_value *s1, const mrb_value *s2, size_t n)
{
if (n == 0) return;
if (s1 > s2 && s1 < s2 + n)
{
s1 += n;
+1 -1
View File
@@ -1823,7 +1823,7 @@ RETRY_TRY_BLOCK:
if (kd) regs[len + 1] = kdict;
/* copy mandatory and optional arguments */
if (argv0 != argv) {
if (argv0 != argv && argv) {
value_move(&regs[1], argv, argc-mlen); /* m1 + o */
}
if (argc < m1) {