From da87648470e8674fcfaec25e06ed5b7633566dcc Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Sat, 20 Apr 2019 15:03:38 -0700 Subject: [PATCH] Check nullity of CGColorSpaceCopyICCProfile's return value Happens when the window is minimized or during the laps of time it goes to fullscreen, the CGImage size being 1x1. Issue introduced when adding ICC profile support, see https://webrtc-review.googlesource.com/c/src/+/133580 Bug: chromium:945468 Change-Id: I65e90eaaa8999578f6127c229376ead219d7a795 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133708 Reviewed-by: Sergey Ulanov Commit-Queue: Julien Isorce Cr-Commit-Position: refs/heads/master@{#27832} --- modules/desktop_capture/mac/desktop_frame_cgimage.mm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/desktop_capture/mac/desktop_frame_cgimage.mm b/modules/desktop_capture/mac/desktop_frame_cgimage.mm index dddf4a4e1a..fb13fe2738 100644 --- a/modules/desktop_capture/mac/desktop_frame_cgimage.mm +++ b/modules/desktop_capture/mac/desktop_frame_cgimage.mm @@ -74,11 +74,13 @@ std::unique_ptr DesktopFrameCGImage::CreateFromCGImage( CGColorSpaceRef cg_color_space = CGImageGetColorSpace(cg_image.get()); if (cg_color_space) { rtc::ScopedCFTypeRef cf_icc_profile(CGColorSpaceCopyICCProfile(cg_color_space)); - const uint8_t* data_as_byte = - reinterpret_cast(CFDataGetBytePtr(cf_icc_profile.get())); - const size_t data_size = CFDataGetLength(cf_icc_profile.get()); - if (data_as_byte && data_size > 0) { - frame->set_icc_profile(std::vector(data_as_byte, data_as_byte + data_size)); + if (cf_icc_profile) { + const uint8_t* data_as_byte = + reinterpret_cast(CFDataGetBytePtr(cf_icc_profile.get())); + const size_t data_size = CFDataGetLength(cf_icc_profile.get()); + if (data_as_byte && data_size > 0) { + frame->set_icc_profile(std::vector(data_as_byte, data_as_byte + data_size)); + } } }