From 6733345f73d04aeca9fa94706ca7451a72433429 Mon Sep 17 00:00:00 2001 From: Lukas Tenbrink Date: Fri, 17 Oct 2025 12:28:30 +0200 Subject: [PATCH] Fix false positive warning with `FixedVector` array bounds in gcc. --- core/templates/fixed_vector.h | 4 ++++ scene/main/multiplayer_peer.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/core/templates/fixed_vector.h b/core/templates/fixed_vector.h index ba50d59e3ab..e56f9fdf0ec 100644 --- a/core/templates/fixed_vector.h +++ b/core/templates/fixed_vector.h @@ -32,6 +32,8 @@ #include "core/templates/span.h" +GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Warray-bounds") + /** * A high performance Vector of fixed capacity. * Especially useful if you need to create an array on the stack, to @@ -201,3 +203,5 @@ public: _FORCE_INLINE_ constexpr const T *begin() const { return ptr(); } _FORCE_INLINE_ constexpr const T *end() const { return ptr() + _size; } }; + +GODOT_GCC_WARNING_POP diff --git a/scene/main/multiplayer_peer.cpp b/scene/main/multiplayer_peer.cpp index 4d4a12150cf..407353ffb84 100644 --- a/scene/main/multiplayer_peer.cpp +++ b/scene/main/multiplayer_peer.cpp @@ -151,6 +151,7 @@ Error MultiplayerPeerExtension::get_packet(const uint8_t **r_buffer, int &r_buff } Error MultiplayerPeerExtension::put_packet(const uint8_t *p_buffer, int p_buffer_size) { + ERR_FAIL_COND_V(p_buffer_size < 0, ERR_INVALID_PARAMETER); Error err; if (GDVIRTUAL_CALL(_put_packet, p_buffer, p_buffer_size, err)) { return err;