From fd986387262cbcdfe9235aff265d7065cf86b38d Mon Sep 17 00:00:00 2001 From: Qiu Jianlin Date: Wed, 31 Jul 2024 21:32:41 +0800 Subject: [PATCH] Check empty slice in H.265 bitstream parser. This is cherry-picked from WebKit's PR by youenn@apple.com. The original PR: https://github.com/WebKit/WebKit/pull/31525 Bug: chromium:41480904 Change-Id: I69c7c8d5842a576fa18432fb9f85c6890b47f3ed Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/358200 Commit-Queue: Jianlin Qiu Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#42708} --- common_video/h265/h265_bitstream_parser.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common_video/h265/h265_bitstream_parser.cc b/common_video/h265/h265_bitstream_parser.cc index c9d17b0628..ee41a79cc7 100644 --- a/common_video/h265/h265_bitstream_parser.cc +++ b/common_video/h265/h265_bitstream_parser.cc @@ -419,6 +419,10 @@ const H265SpsParser::SpsState* H265BitstreamParser::GetSPS(uint32_t id) const { } void H265BitstreamParser::ParseSlice(rtc::ArrayView slice) { + if (slice.empty()) { + RTC_LOG(LS_WARNING) << "Empty slice in H265 bitstream."; + return; + } H265::NaluType nalu_type = H265::ParseNaluType(slice[0]); switch (nalu_type) { case H265::NaluType::kVps: {