From b069b32c643e0f315c008b568aa1142f165a17bb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 4 Oct 2010 11:19:41 +0000 Subject: [PATCH] Added checks for NULL images to prevent crashes when no valid images are created --- examples/osgvolume/osgvolume.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/osgvolume/osgvolume.cpp b/examples/osgvolume/osgvolume.cpp index c6c0d3265..cc07b156f 100644 --- a/examples/osgvolume/osgvolume.cpp +++ b/examples/osgvolume/osgvolume.cpp @@ -1109,7 +1109,6 @@ int main( int argc, char **argv ) { // not an option so assume string is a filename. osg::Image *image = osgDB::readImageFile( arguments[pos]); - if(image) { imageList.push_back(image); @@ -1120,7 +1119,8 @@ int main( int argc, char **argv ) // pack the textures into a single texture. ProcessRow processRow; - images.push_back(createTexture3D(imageList, processRow, numComponentsDesired, s_maximumTextureSize, t_maximumTextureSize, r_maximumTextureSize, resizeToPowerOfTwo)); + osg::Image* image = createTexture3D(imageList, processRow, numComponentsDesired, s_maximumTextureSize, t_maximumTextureSize, r_maximumTextureSize, resizeToPowerOfTwo); + if (image) images.push_back(image); } @@ -1144,8 +1144,8 @@ int main( int argc, char **argv ) if (osgDB::getLowerCaseFileExtension(filename)=="dicom") { // not an option so assume string is a filename. - osg::Image *image = osgDB::readImageFile(filename); - if(image) + osg::Image* image = osgDB::readImageFile(filename); + if (image) { images.push_back(image); } @@ -1161,16 +1161,14 @@ int main( int argc, char **argv ) if (fileType == osgDB::DIRECTORY) { - osg::Image *image = osgDB::readImageFile(filename+".dicom"); - if(image) - { - images.push_back(image); - } + osg::Image* image = osgDB::readImageFile(filename+".dicom"); + if (image) images.push_back(image); } else if (fileType == osgDB::REGULAR_FILE) { // not an option so assume string is a filename. - images.push_back(osgDB::readImageFile( filename )); + osg::Image* image = osgDB::readImageFile( filename ); + if (image) images.push_back(image); } else {