diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index be6b6c817..b26044e3c 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -99,6 +99,7 @@ void info_callback(const char* msg, void*) LLImageJ2COJ::LLImageJ2COJ() : LLImageJ2CImpl() { + mRawImagep=NULL; } @@ -166,9 +167,17 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod // The image decode failed if the return was NULL or the component // count was zero. The latter is just a sanity check before we // dereference the array. - if(!image || !image->numcomps) + if(!image) { - llwarns << "ERROR -> decodeImpl: failed to decode image!" << llendl; + LL_DEBUGS("Openjpeg") << "ERROR -> decodeImpl: failed to decode image - no image" << LL_ENDL; + return TRUE; // done + } + + S32 img_components = image->numcomps; + + if( !img_components ) // < 1 ||img_components > 4 ) + { + LL_DEBUGS("Openjpeg") << "ERROR -> decodeImpl: failed to decode image wrong number of components: " << img_components << LL_ENDL; if (image) { opj_image_destroy(image); @@ -178,20 +187,21 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod } // sometimes we get bad data out of the cache - check to see if the decode succeeded - for (S32 i = 0; i < image->numcomps; i++) + for (S32 i = 0; i < img_components; i++) { if (image->comps[i].factor != base.getRawDiscardLevel()) { // if we didn't get the discard level we're expecting, fail - opj_image_destroy(image); + if (image) //anyway somthing odd with the image, better check than crash + opj_image_destroy(image); base.mDecoding = FALSE; return TRUE; } } - if(image->numcomps <= first_channel) + if(img_components <= first_channel) { - llwarns << "trying to decode more channels than are present in image: numcomps: " << image->numcomps << " first_channel: " << first_channel << llendl; + LL_DEBUGS("Openjpeg") << "trying to decode more channels than are present in image: numcomps: " << img_components << " first_channel: " << first_channel << LL_ENDL; if (image) { opj_image_destroy(image); @@ -202,7 +212,6 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod // Copy image data into our raw image format (instead of the separate channel format - S32 img_components = image->numcomps; S32 channels = img_components - first_channel; if( channels > max_channel_count ) channels = max_channel_count; @@ -249,7 +258,10 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod } /* free image data structure */ - opj_image_destroy(image); + if (image) + { + opj_image_destroy(image); + } return TRUE; // done } diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 95386d12b..be7b3aece 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1016,8 +1016,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S mFormatType = GL_UNSIGNED_BYTE; break; default: - //HACKY MCHACK HACK - llinfos << "Bad number of components for texture: " << (U32)getComponents() << llendl; + LL_DEBUGS("Openjpeg") << "Bad number of components for texture: " << (U32)getComponents() << LL_ENDL; to_create = false; } } diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index a49ccb77b..6bf7613f7 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -40,7 +40,8 @@ tags - ShaderLoading + ShaderLoading + Openjpeg