From 8654e90759caf2463a3b643fdbb8883168b10cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Fri, 5 May 2023 12:50:10 +0200 Subject: [PATCH] Mend some checks in CallQueue --- core/object/message_queue.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/object/message_queue.cpp b/core/object/message_queue.cpp index 83e0c4aea1..cfd8904af6 100644 --- a/core/object/message_queue.cpp +++ b/core/object/message_queue.cpp @@ -62,15 +62,16 @@ Error CallQueue::push_set(Object *p_object, const StringName &p_prop, const Vari } Error CallQueue::push_callablep(const Callable &p_callable, const Variant **p_args, int p_argcount, bool p_show_error) { - mutex.lock(); uint32_t room_needed = sizeof(Message) + sizeof(Variant) * p_argcount; ERR_FAIL_COND_V_MSG(room_needed > uint32_t(PAGE_SIZE_BYTES), ERR_INVALID_PARAMETER, "Message is too large to fit on a page (" + itos(PAGE_SIZE_BYTES) + " bytes), consider passing less arguments."); + mutex.lock(); + _ensure_first_page(); if ((page_offset + room_needed) > uint32_t(PAGE_SIZE_BYTES)) { - if (room_needed > uint32_t(PAGE_SIZE_BYTES) || pages_used == max_pages) { + if (pages_used == max_pages) { ERR_PRINT("Failed method: " + p_callable + ". Message queue out of memory. " + error_text); statistics(); mutex.unlock();