From e7b2972fc8fc1cf6ea32630910a870446c632ae6 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 1 Feb 2012 03:33:39 +0100 Subject: [PATCH] LLVFile::readFile must return LLPrivateMemoryPool allocated data. --- indra/llvfs/llvfile.cpp | 6 +++--- indra/llvfs/llvfile.h | 4 +++- indra/newview/lltexlayer.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp index 7e60c0fd5..419d1b76c 100644 --- a/indra/llvfs/llvfile.cpp +++ b/indra/llvfs/llvfile.cpp @@ -130,7 +130,7 @@ BOOL LLVFile::read(U8 *buffer, S32 bytes, BOOL async, F32 priority) } //static -U8* LLVFile::readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read) +U8* LLVFile::readFile(LLVFS *vfs, LLPrivateMemoryPool* poolp, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read) { U8 *data; LLVFile file(vfs, uuid, type, LLVFile::READ); @@ -142,12 +142,12 @@ U8* LLVFile::readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S } else { - data = new U8[file_size]; + data = (U8*)ALLOCATE_MEM(poolp, file_size); file.read(data, file_size); /* Flawfinder: ignore */ if (file.getLastBytesRead() != (S32)file_size) { - delete[] data; + FREE_MEM(poolp, data); data = NULL; file_size = 0; } diff --git a/indra/llvfs/llvfile.h b/indra/llvfs/llvfile.h index c3bca8c73..6a112cc45 100644 --- a/indra/llvfs/llvfile.h +++ b/indra/llvfs/llvfile.h @@ -38,6 +38,8 @@ #include "llvfs.h" #include "llvfsthread.h" +class LLPrivateMemoryPool; + class LLVFile { public: @@ -45,7 +47,7 @@ public: ~LLVFile(); BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f); /* Flawfinder: ignore */ - static U8* readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0); + static U8* readFile(LLVFS *vfs, LLPrivateMemoryPool* poolp, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0); void setReadPriority(const F32 priority); BOOL isReadComplete(); S32 getLastBytesRead(); diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index 06f72c774..9bd5ebf94 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -402,7 +402,7 @@ void LLTexLayerSetBuffer::readBackAndUpload() BOOL valid = FALSE; LLPointer integrity_test = new LLImageJ2C; S32 file_size = 0; - U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size); + U8* data = LLVFile::readFile(gVFS, LLImageBase::getPrivatePool(), asset_id, LLAssetType::AT_TEXTURE, &file_size); if (data) { valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data'