Index: Branch_1-20-Viewer/indra/llimagej2coj/llimagej2coj.cpp
===================================================================
--- Branch_1-20-Viewer.orig/indra/llimagej2coj/llimagej2coj.cpp	2008-04-22 23:08:17.000000000 +0200
+++ Branch_1-20-Viewer/indra/llimagej2coj/llimagej2coj.cpp	2008-04-23 17:55:15.000000000 +0200
@@ -170,6 +170,15 @@
 		}
 	}
 	
+	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
 
 	S32 img_components = image->numcomps;
