summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2016-10-19 01:12:52 +0300
committerAndreyL ProductEngine <alihatskiy@productengine.com>2016-10-19 01:12:52 +0300
commitf75ea457c836d73d6bdbbeed77536c74c1482f29 (patch)
treeb29986e3e86862bb51e6d876373cd0d60c0db51b
parent30c8ea4d2c0c48e18835c32dafc35d3e16a2b2d9 (diff)
MAINT-6818 Fix for LLImageBase::allocateData crash
-rw-r--r--indra/llimage/llimage.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index f71607096c..43b6b3bcd6 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -705,18 +705,21 @@ void LLImageBase::deleteData()
// virtual
U8* LLImageBase::allocateData(S32 size)
{
+ //make this function thread-safe.
+ static const U32 MAX_BUFFER_SIZE = 4096 * 4096 * 16; //256 MB
+ mBadBufferAllocation = false;
+
if (size < 0)
{
size = mWidth * mHeight * mComponents;
if (size <= 0)
{
- LL_ERRS() << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,(S32)mComponents) << LL_ENDL;
+ LL_WARNS() << llformat("LLImageBase::allocateData called with bad dimensions: %dx%dx%d",mWidth,mHeight,(S32)mComponents) << LL_ENDL;
+ mBadBufferAllocation = true;
}
- }
-
- //make this function thread-safe.
- static const U32 MAX_BUFFER_SIZE = 4096 * 4096 * 16 ; //256 MB
- if (size < 1 || size > MAX_BUFFER_SIZE)
+ }
+
+ if (!mBadBufferAllocation && (size < 1 || size > MAX_BUFFER_SIZE))
{
LL_INFOS() << "width: " << mWidth << " height: " << mHeight << " components: " << mComponents << LL_ENDL ;
if(mAllowOverSize)
@@ -725,25 +728,31 @@ U8* LLImageBase::allocateData(S32 size)
}
else
{
- LL_ERRS() << "LLImageBase::allocateData: bad size: " << size << LL_ENDL;
+ LL_WARNS() << "LLImageBase::allocateData: bad size: " << size << LL_ENDL;
+ mBadBufferAllocation = true;
}
}
- if (!mData || size != mDataSize)
+
+ if (!mBadBufferAllocation && (!mData || size != mDataSize))
{
deleteData(); // virtual
- mBadBufferAllocation = false ;
mData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size);
if (!mData)
{
LL_WARNS() << "Failed to allocate image data size [" << size << "]" << LL_ENDL;
- size = 0 ;
- mWidth = mHeight = 0 ;
- mBadBufferAllocation = true ;
+ mBadBufferAllocation = true;
}
- mDataSize = size;
- claimMem(mDataSize);
}
+ if (mBadBufferAllocation)
+ {
+ size = 0;
+ mWidth = mHeight = 0;
+ mData = NULL;
+ }
+ mDataSize = size;
+ claimMem(mDataSize);
+
return mData;
}