Bug 254410

Summary: [CG] Handle properly the case when an image does not have a valid output colorspace
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: ImagesAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: sabouhallawa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=229021

Description Said Abou-Hallawa 2023-03-24 06:15:15 PDT
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.
Comment 1 Said Abou-Hallawa 2023-03-24 06:15:27 PDT
rdar://107103646
Comment 2 Said Abou-Hallawa 2023-03-24 06:16:17 PDT
rdar://107103646
Comment 3 Said Abou-Hallawa 2023-03-24 06:25:14 PDT
Pull request: https://github.com/WebKit/WebKit-security/pull/33
Comment 4 Said Abou-Hallawa 2023-03-24 08:50:01 PDT
Pull request: https://github.com/WebKit/WebKit/pull/11928
Comment 5 Said Abou-Hallawa 2023-03-27 23:01:38 PDT
This is already fixed by bug 254406.

*** This bug has been marked as a duplicate of bug 254406 ***