diff --git a/src/logic/scripting/lua/libs/libnetwork.cpp b/src/logic/scripting/lua/libs/libnetwork.cpp index 61d44de78..dc7527104 100644 --- a/src/logic/scripting/lua/libs/libnetwork.cpp +++ b/src/logic/scripting/lua/libs/libnetwork.cpp @@ -101,7 +101,8 @@ static int l_recv(lua::State* L) { if (connection == nullptr) { return 0; } - util::Buffer buffer(glm::min(length, connection->available())); + length = glm::min(length, connection->available()); + util::Buffer buffer(length); int size = connection->recv(buffer.data(), length); if (size == -1) {