From b32e6c168a3463c1eda7a94f7716adbd3d607a38 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 15 Jun 2021 15:55:52 +0900 Subject: [PATCH] Convert initial contents before allocating queue buffer --- thread_sync.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/thread_sync.c b/thread_sync.c index e9eabb45ca..76bf57e4dd 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -859,11 +859,13 @@ rb_queue_initialize(int argc, VALUE *argv, VALUE self) { VALUE initial; struct rb_queue *q = queue_ptr(self); + if ((argc = rb_scan_args(argc, argv, "01", &initial)) == 1) { + initial = rb_to_array(initial); + } RB_OBJ_WRITE(self, &q->que, ary_buf_new()); list_head_init(queue_waitq(q)); - rb_scan_args(argc, argv, "01", &initial); if (argc == 1) { - rb_ary_concat(q->que, rb_to_array(initial)); + rb_ary_concat(q->que, initial); } return self; }