lib/free-image/sources/abstract_source.rb in free-image-0.6.1 vs lib/free-image/sources/abstract_source.rb in free-image-0.6.2

- old
+ new

@@ -164,9 +164,16 @@ unless FreeImage.FreeImage_FIFSupportsReading(format) raise(Error.new("Cannot load image")) end ptr = load(format, flags) + + # Make sure we didn't get a null pointer. This can + # happen - see test_file for example#test_corrupt_wrong_format + if ptr.null? + error = Error.new(:unknown, "Could not load the image") + raise(error) + end Bitmap.new(ptr, self) end end end \ No newline at end of file