From f09b9576c651348ea00e2d7915383a5db0afcf5f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 5 Nov 2012 17:22:34 +0000 Subject: [PATCH] From Stephan Huber, "Attached you'll find a fix for the image-io-plugin to handle out-of-memory situations more gracefully as before (don't crash)" --- src/osgPlugins/imageio/ReaderWriterImageIO.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/imageio/ReaderWriterImageIO.cpp b/src/osgPlugins/imageio/ReaderWriterImageIO.cpp index ca65ccc98..8c8efa06f 100644 --- a/src/osgPlugins/imageio/ReaderWriterImageIO.cpp +++ b/src/osgPlugins/imageio/ReaderWriterImageIO.cpp @@ -364,6 +364,7 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef image_ref) } } + // Sets up a context to be drawn to with image_data as the area to be drawn to CGContextRef bitmap_context = CGBitmapContextCreate( @@ -380,6 +381,9 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef image_ref) CGContextDrawImage(bitmap_context, the_rect, image_ref); CGContextRelease(bitmap_context); + + if (!image_data) + return NULL; // // Reverse the premultiplied alpha for avoiding unexpected darker edges @@ -1173,7 +1177,9 @@ public: osg::Image* osg_image = CreateOSGImageFromCGImage(cg_image_ref); CFRelease(cg_image_ref); - + if (!osg_image) + return ReadResult::INSUFFICIENT_MEMORY_TO_LOAD; + return osg_image; }