1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-08-18 15:25:05 +02:00

hevc: Search start code in decode_nal_units().

User may cut off a weird position and send a packet from there.
This avoids returning as invalid data immediately.
This commit is contained in:
Yusuke Nakamura 2013-10-21 02:36:51 +09:00 committed by Mickaël Raulet
parent 610a8b1537
commit f7f8801839

View File

@ -2325,14 +2325,15 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
goto fail;
}
} else {
if (buf[2] == 0) {
length--;
buf++;
continue;
}
if (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
ret = AVERROR_INVALIDDATA;
goto fail;
/* search start code */
while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) {
++buf;
--length;
if (length < 4) {
av_log(s->avctx, AV_LOG_ERROR, "No start code is found.\n");
ret = AVERROR_INVALIDDATA;
goto fail;
}
}
buf += 3;