From 429ba35a066a20ef7fbce9ea50f712f2bb35452c Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Fri, 5 Mar 2021 00:46:12 -0500 Subject: [PATCH] Fix mesh cache to actually work. --- indra/newview/llmeshrepository.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 7d46ddf4178..19f2a016465 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -3279,18 +3279,20 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b S32 bytes = lod_bytes + header_bytes; - - // It's possible for the remote asset to have more data than is needed for the local cache - // only allocate as much space in the cache as is needed for the local cache + // It's possible for the data portion to be smaller then the actual data size...clamp to avoid buffer hammer data_size = llmin(data_size, bytes); + std::vector<U8> padded_data; + padded_data.resize(bytes); + memcpy(padded_data.data(), data, data_size); + LLFileSystem file(mesh_id, LLAssetType::AT_MESH, LLFileSystem::WRITE); - if (file.getMaxSize() >= bytes) + if (file.getMaxSize() >= padded_data.size()) { - LLMeshRepository::sCacheBytesWritten += data_size; + LLMeshRepository::sCacheBytesWritten += padded_data.size(); ++LLMeshRepository::sCacheWrites; - file.write(data, data_size); + file.write(padded_data.data(), padded_data.size()); } } else -- GitLab