diff options
| author | Ankur Ahlawat <anchor@lindenlab.com> | 2018-03-07 10:00:07 -0800 |
|---|---|---|
| committer | Ankur Ahlawat <anchor@lindenlab.com> | 2018-03-07 10:00:07 -0800 |
| commit | ac558e384214e22b4a8da2045854e2180b7428bf (patch) | |
| tree | 7de576ff5552cbb9956c6cdf0e4d84b52514316e /indra/llrender/llimagegl.cpp | |
| parent | 485193c7f530fa3d8574c74304e452ab6d012e41 (diff) | |
| parent | f8c76535a35aaf245e261357a59e977bac5b2501 (diff) | |
Merged lindenlab/viewer-release into default
Diffstat (limited to 'indra/llrender/llimagegl.cpp')
| -rw-r--r-- | indra/llrender/llimagegl.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 20cba68f84..89500dcc04 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -622,7 +622,7 @@ void LLImageGL::setImage(const LLImageRaw* imageraw) } static LLTrace::BlockTimerStatHandle FTM_SET_IMAGE("setImage"); -void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) +BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) { LL_RECORD_BLOCK_TIME(FTM_SET_IMAGE); bool is_compressed = false; @@ -787,19 +787,33 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) llassert(prev_mip_data); llassert(cur_mip_size == bytes*4); #endif - U8* new_data = new U8[bytes]; + U8* new_data = new(std::nothrow) U8[bytes]; + if (!new_data) + { + stop_glerror(); + + if (prev_mip_data) + delete[] prev_mip_data; + if (cur_mip_data) + delete[] cur_mip_data; + + mGLTextureCreated = false; + return FALSE; + } + else + { #ifdef SHOW_ASSERT - llassert(prev_mip_data); - llassert(cur_mip_size == bytes*4); - llassert_always(new_data); + llassert(prev_mip_data); + llassert(cur_mip_size == bytes * 4); #endif - LLImageBase::generateMip(prev_mip_data, new_data, w, h, mComponents); - cur_mip_data = new_data; + LLImageBase::generateMip(prev_mip_data, new_data, w, h, mComponents); + cur_mip_data = new_data; #ifdef SHOW_ASSERT - cur_mip_size = bytes; + cur_mip_size = bytes; #endif + } } llassert(w > 0 && h > 0 && cur_mip_data); @@ -886,6 +900,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } stop_glerror(); mGLTextureCreated = true; + return TRUE; } BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image) @@ -1355,8 +1370,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ if (mTexName != 0 && discard_level == mCurrentDiscardLevel) { // This will only be true if the size has not changed - setImage(data_in, data_hasmips); - return TRUE; + return setImage(data_in, data_hasmips); } U32 old_name = mTexName; @@ -1398,7 +1412,11 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ mCurrentDiscardLevel = discard_level; - setImage(data_in, data_hasmips); + if (!setImage(data_in, data_hasmips)) + { + stop_glerror(); + return FALSE; + } // Set texture options to our defaults. gGL.getTexUnit(0)->setHasMipMaps(mHasMipMaps); |
