From: Nicolas Dufresne Date: Thu, 7 May 2020 02:18:12 +0000 (-0400) Subject: h265parser: Fix NAL size check for identification X-Git-Tag: 1.19.3~507^2~1911 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9029631f752d004912a02b775002579f414a2b33;p=platform%2Fupstream%2Fgstreamer.git h265parser: Fix NAL size check for identification Unlike H264, H265 requires 2 bytes after the start code to allow NAL identification. This would otherwise report a broken NAL and skip important data. Fixes #1287 Part-of: --- diff --git a/gst-libs/gst/codecparsers/gsth265parser.c b/gst-libs/gst/codecparsers/gsth265parser.c index 7dea822..dc8db4c 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.c +++ b/gst-libs/gst/codecparsers/gsth265parser.c @@ -1414,6 +1414,13 @@ gst_h265_parser_identify_nalu_unchecked (GstH265Parser * parser, nalu->sc_offset = offset + off1; + /* The scanner ensures one byte passed the start code but to + * identify an HEVC NAL, we need 2. */ + if (size - nalu->sc_offset - 3 < 2) { + GST_DEBUG ("Not enough bytes after start code to identify"); + return GST_H265_PARSER_NO_NAL; + } + /* sc might have 2 or 3 0-bytes */ if (nalu->sc_offset > 0 && data[nalu->sc_offset - 1] == 00) nalu->sc_offset--;