summaryrefslogtreecommitdiff
path: root/indra/llimage/llpngwrapper.cpp
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2018-07-26 20:06:26 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2018-07-26 20:06:26 +0300
commite24d4c9f4d2f37ee80685c6ab276633b94b366b8 (patch)
treed78c2549bb124973e87cce4f53273fd7a2e01687 /indra/llimage/llpngwrapper.cpp
parent8c8a44f430cc373d3a09308c5efdc420c1571d11 (diff)
MAINT-8923 Better allocation failure handling, createGLTexture crashes
Diffstat (limited to 'indra/llimage/llpngwrapper.cpp')
-rw-r--r--indra/llimage/llpngwrapper.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/indra/llimage/llpngwrapper.cpp b/indra/llimage/llpngwrapper.cpp
index eb70b78a36..f298764cc0 100644
--- a/indra/llimage/llpngwrapper.cpp
+++ b/indra/llimage/llpngwrapper.cpp
@@ -173,8 +173,11 @@ BOOL LLPngWrapper::readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInf
// data space
if (rawImage != NULL)
{
- rawImage->resize(static_cast<U16>(mWidth),
- static_cast<U16>(mHeight), mChannels);
+ if (!rawImage->resize(static_cast<U16>(mWidth),
+ static_cast<U16>(mHeight), mChannels))
+ {
+ LLTHROW(PngError("Failed to resize image"));
+ }
U8 *dest = rawImage->getData();
int offset = mWidth * mChannels;
@@ -207,6 +210,12 @@ BOOL LLPngWrapper::readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInf
releaseResources();
return (FALSE);
}
+ catch (std::bad_alloc)
+ {
+ mErrorMessage = "LLPngWrapper";
+ releaseResources();
+ return (FALSE);
+ }
// Clean up and return
releaseResources();