Fix crash in RTCMTLVideoView when trying to draw an invalid sized frame

Bug: webrtc:14892
Change-Id: I6321380444fa1de34c64fe72b587f1f5b245fad8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304000
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39971}
This commit is contained in:
Saúl Ibarra Corretgé 2023-05-02 10:00:54 +02:00 committed by WebRTC LUCI CQ
parent f42cfc56a9
commit 14d4e9f186

View File

@ -116,6 +116,13 @@ static NSString *const shaderSource = MTL_STRINGIFY(
return NO;
}
// Chroma size must be >= 1 as per the Apple documentation, so skip ?x1
// and 1x? frames.
// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=14892
if (frame.width < 2 || frame.height < 2) {
return NO;
}
id<RTC_OBJC_TYPE(RTCI420Buffer)> buffer = [frame.buffer toI420];
// Luma (y) texture.