aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden
diff options
context:
space:
mode:
authorArmin Weatherwax2010-02-03 17:10:57 +0100
committerJacek Antonelli2010-02-22 01:39:11 -0600
commit973f07db7982e78c634c29f6139dea547a111141 (patch)
treed98b613386f9de0151a7b8528ac366d700b5e91c /linden
parentFixed an error at shutdown (gSavedSettings.cleanup). (diff)
downloadmeta-impy-973f07db7982e78c634c29f6139dea547a111141.zip
meta-impy-973f07db7982e78c634c29f6139dea547a111141.tar.gz
meta-impy-973f07db7982e78c634c29f6139dea547a111141.tar.bz2
meta-impy-973f07db7982e78c634c29f6139dea547a111141.tar.xz
Fixed a rare crash from textures with too many components.
Only seen in lbsa plaza on OSGrid, so far.
Diffstat (limited to 'linden')
-rw-r--r--linden/indra/llimagej2coj/llimagej2coj.cpp29
-rw-r--r--linden/indra/llrender/llimagegl.cpp4
-rw-r--r--linden/indra/newview/app_settings/logcontrol.xml2
3 files changed, 25 insertions, 10 deletions
diff --git a/linden/indra/llimagej2coj/llimagej2coj.cpp b/linden/indra/llimagej2coj/llimagej2coj.cpp
index be6b6c8..b7a1b82 100644
--- a/linden/indra/llimagej2coj/llimagej2coj.cpp
+++ b/linden/indra/llimagej2coj/llimagej2coj.cpp
@@ -99,6 +99,7 @@ void info_callback(const char* msg, void*)
99 99
100LLImageJ2COJ::LLImageJ2COJ() : LLImageJ2CImpl() 100LLImageJ2COJ::LLImageJ2COJ() : LLImageJ2CImpl()
101{ 101{
102 mRawImagep=NULL;
102} 103}
103 104
104 105
@@ -166,9 +167,17 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
166 // The image decode failed if the return was NULL or the component 167 // The image decode failed if the return was NULL or the component
167 // count was zero. The latter is just a sanity check before we 168 // count was zero. The latter is just a sanity check before we
168 // dereference the array. 169 // dereference the array.
169 if(!image || !image->numcomps) 170 if(!image)
170 { 171 {
171 llwarns << "ERROR -> decodeImpl: failed to decode image!" << llendl; 172 LL_DEBUGS("Openjpeg") << "ERROR -> decodeImpl: failed to decode image - no image" << LL_ENDL;
173 return TRUE; // done
174 }
175
176 S32 img_components = image->numcomps;
177
178 if( !img_components ) // < 1 ||img_components > 4 )
179 {
180 LL_DEBUGS("Openjpeg") << "ERROR -> decodeImpl: failed to decode image wrong number of components: " << img_components << LL_ENDL;
172 if (image) 181 if (image)
173 { 182 {
174 opj_image_destroy(image); 183 opj_image_destroy(image);
@@ -178,20 +187,21 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
178 } 187 }
179 188
180 // sometimes we get bad data out of the cache - check to see if the decode succeeded 189 // sometimes we get bad data out of the cache - check to see if the decode succeeded
181 for (S32 i = 0; i < image->numcomps; i++) 190 for (S32 i = 0; i < img_components; i++)
182 { 191 {
183 if (image->comps[i].factor != base.getRawDiscardLevel()) 192 if (image->comps[i].factor != base.getRawDiscardLevel())
184 { 193 {
185 // if we didn't get the discard level we're expecting, fail 194 // if we didn't get the discard level we're expecting, fail
186 opj_image_destroy(image); 195 if (image) //anyway somthing odd with the image, better check than crash
196 opj_image_destroy(image);
187 base.mDecoding = FALSE; 197 base.mDecoding = FALSE;
188 return TRUE; 198 return TRUE;
189 } 199 }
190 } 200 }
191 201
192 if(image->numcomps <= first_channel) 202 if(img_components <= first_channel)
193 { 203 {
194 llwarns << "trying to decode more channels than are present in image: numcomps: " << image->numcomps << " first_channel: " << first_channel << llendl; 204 LL_DEBUGS("Openjpeg") << "trying to decode more channels than are present in image: numcomps: " << img_components << " first_channel: " << first_channel << LL_ENDL;
195 if (image) 205 if (image)
196 { 206 {
197 opj_image_destroy(image); 207 opj_image_destroy(image);
@@ -202,7 +212,7 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
202 212
203 // Copy image data into our raw image format (instead of the separate channel format 213 // Copy image data into our raw image format (instead of the separate channel format
204 214
205 S32 img_components = image->numcomps; 215
206 S32 channels = img_components - first_channel; 216 S32 channels = img_components - first_channel;
207 if( channels > max_channel_count ) 217 if( channels > max_channel_count )
208 channels = max_channel_count; 218 channels = max_channel_count;
@@ -249,7 +259,10 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
249 } 259 }
250 260
251 /* free image data structure */ 261 /* free image data structure */
252 opj_image_destroy(image); 262 if (image)
263 {
264 opj_image_destroy(image);
265 }
253 266
254 return TRUE; // done 267 return TRUE; // done
255} 268}
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp
index 27b1d55..544eb80 100644
--- a/linden/indra/llrender/llimagegl.cpp
+++ b/linden/indra/llrender/llimagegl.cpp
@@ -1014,7 +1014,9 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
1014 mFormatType = GL_UNSIGNED_BYTE; 1014 mFormatType = GL_UNSIGNED_BYTE;
1015 break; 1015 break;
1016 default: 1016 default:
1017 llerrs << "Bad number of components for texture: " << (U32)getComponents() << llendl; 1017 LL_DEBUGS("Openjpeg") << "Bad number of components for texture: " << (U32)getComponents() << LL_ENDL;
1018 to_create = false;
1019 break;
1018 } 1020 }
1019 } 1021 }
1020 1022
diff --git a/linden/indra/newview/app_settings/logcontrol.xml b/linden/indra/newview/app_settings/logcontrol.xml
index 60f78b7..401b145 100644
--- a/linden/indra/newview/app_settings/logcontrol.xml
+++ b/linden/indra/newview/app_settings/logcontrol.xml
@@ -51,7 +51,7 @@
51 <string>MediaState</string> 51 <string>MediaState</string>
52 <string>ShaderLoading</string> 52 <string>ShaderLoading</string>
53 <string>XMLNode</string> 53 <string>XMLNode</string>
54 54 <string>Openjpeg</string>
55 <!--Unused debug messages below--> 55 <!--Unused debug messages below-->
56 56
57 <!--<string>RLV</string> 57 <!--<string>RLV</string>