NativeImage::colorSpace() always creates DestinationColorSpace from the return of CGImageGetColorSpace() without checking its value which can be null. We need to check the image colorspace is CGColorSpaceSupportsOutput() before creating DestinationColorSpace. CGColorSpaceSupportsOutput() will return false for a null input. We can make the return type of NativeImage::colorSpace() std::optional<DestinationColorSpace> and make it return std::nullopt if CGColorSpaceSupportsOutput() returns false. We should let the caller decide what to do when the image does not have a valid DestinationColorSpace.
rdar://107103646
Pull request: https://github.com/WebKit/WebKit-security/pull/33
Pull request: https://github.com/WebKit/WebKit/pull/11928
This is already fixed by bug 254406. *** This bug has been marked as a duplicate of bug 254406 ***