From fc5a3e27af57d57ff17b70c1085ed3d4b63445ef Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sat, 7 Mar 2009 09:25:32 -0700 Subject: Backported fix for VWR-4070 from 1.22 --- ChangeLog.txt | 6 ++++++ linden/indra/llimagej2coj/llimagej2coj.cpp | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 23b79da..fd8ba2e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,9 @@ +2009-03-07 McCabe Maxsted + + * linden/indra/llimagej2coj/llimagej2coj.cpp: + Backported fix for VWR-4070 from 1.22. + + 2009-03-01 McCabe Maxsted * linden/indra/newview/llfloaterchat.cpp: diff --git a/linden/indra/llimagej2coj/llimagej2coj.cpp b/linden/indra/llimagej2coj/llimagej2coj.cpp index 983241c..a0c61d8 100644 --- a/linden/indra/llimagej2coj/llimagej2coj.cpp +++ b/linden/indra/llimagej2coj/llimagej2coj.cpp @@ -151,9 +151,11 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod // dereference the array. if(!image || !image->numcomps) { - fprintf(stderr, "ERROR -> decodeImpl: failed to decode image!\n"); + llwarns << "ERROR -> decodeImpl: failed to decode image!" << llendl; if (image) + { opj_image_destroy(image); + } return TRUE; // done } @@ -169,6 +171,17 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod return TRUE; } } + + if(image->numcomps <= first_channel) + { + llwarns << "trying to decode more channels than are present in image: numcomps: " << image->numcomps << " first_channel: " << first_channel << llendl; + if (image) + { + opj_image_destroy(image); + } + + return TRUE; + } // Copy image data into our raw image format (instead of the separate channel format @@ -211,7 +224,7 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod } else // Some rare OpenJPEG versions have this bug. { - fprintf(stderr, "ERROR -> decodeImpl: failed to decode image! (NULL comp data - OpenJPEG bug)\n"); + llwarns << "ERROR -> decodeImpl: failed to decode image! (NULL comp data - OpenJPEG bug)" << llendl; opj_image_destroy(image); return TRUE; // done @@ -430,7 +443,7 @@ BOOL LLImageJ2COJ::getMetadata(LLImageJ2C &base) if(!image) { - fprintf(stderr, "ERROR -> getMetadata: failed to decode image!\n"); + llwarns << "ERROR -> getMetadata: failed to decode image!" << llendl; return FALSE; } -- cgit v1.1