diff options
Diffstat (limited to 'indra/llimage/llimage.cpp')
-rw-r--r-- | indra/llimage/llimage.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 7d0de18c7c..1566389e30 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -93,9 +93,10 @@ LLImageBase::LLImageBase() mWidth(0), mHeight(0), mComponents(0), + mBadBufferAllocation(false), + mAllowOverSize(false), mMemType(LLMemType::MTYPE_IMAGEBASE) { - mBadBufferAllocation = FALSE ; } // virtual @@ -134,8 +135,6 @@ void LLImageBase::sanityCheck() } } -BOOL LLImageBase::sSizeOverride = FALSE; - // virtual void LLImageBase::deleteData() { @@ -157,23 +156,32 @@ U8* LLImageBase::allocateData(S32 size) llerrs << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,mComponents) << llendl; } } - if (size < 1 || (size > 4096*4096*16 && sSizeOverride == FALSE)) + + //make this function thread-safe. + static const U32 MAX_BUFFER_SIZE = 4096 * 4096 * 16 ; //256 MB + if (size < 1 || size > MAX_BUFFER_SIZE) { llinfos << "width: " << mWidth << " height: " << mHeight << " components: " << mComponents << llendl ; - llerrs << "LLImageBase::allocateData: bad size: " << size << llendl; + if(mAllowOverSize) + { + llinfos << "Oversize: " << size << llendl ; + } + else + { + llerrs << "LLImageBase::allocateData: bad size: " << size << llendl; + } } - if (!mData || size != mDataSize) { deleteData(); // virtual - mBadBufferAllocation = FALSE ; + mBadBufferAllocation = false ; mData = new U8[size]; if (!mData) { llwarns << "allocate image data: " << size << llendl; size = 0 ; mWidth = mHeight = 0 ; - mBadBufferAllocation = TRUE ; + mBadBufferAllocation = true ; } mDataSize = size; } @@ -222,7 +230,7 @@ U8* LLImageBase::getData() return mData; } -BOOL LLImageBase::isBufferInvalid() +bool LLImageBase::isBufferInvalid() { return mBadBufferAllocation || mData == NULL ; } @@ -258,7 +266,7 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components) : LLImageBase() { mMemType = LLMemType::MTYPE_IMAGERAW; - llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE ); + //llassert( S32(width) * S32(height) * S32(components) <= MAX_IMAGE_DATA_SIZE ); allocateDataSize(width, height, components); ++sRawImageCount; } @@ -1326,7 +1334,7 @@ LLImageFormatted::LLImageFormatted(S8 codec) mCodec(codec), mDecoding(0), mDecoded(0), - mDiscardLevel(0) + mDiscardLevel(-1) { mMemType = LLMemType::MTYPE_IMAGEFORMATTED; } @@ -1545,6 +1553,7 @@ void LLImageFormatted::appendData(U8 *data, S32 size) S32 newsize = cursize + size; reallocateData(newsize); memcpy(getData() + cursize, data, size); + delete[] data; } } } |