X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264.h;h=73562882cdbf8c3604596b4d6fafaf63a1c1c23b;hb=bd074bde02aa11b93958300f06be2a18b549091a;hp=2b5029a74919cc2dcecfb75631f95521f3d15fc9;hpb=27e61a716c893a6ae67ca8f859c735bc0b0b799a;p=ffmpeg diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 2b5029a7491..73562882cdb 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -1191,15 +1191,17 @@ static inline int get_avc_nalsize(H264Context *h, const uint8_t *buf, { int i, nalsize = 0; - if (*buf_index >= buf_size - h->nal_length_size) - return -1; + if (*buf_index >= buf_size - h->nal_length_size) { + // the end of the buffer is reached, refill it. + return AVERROR(EAGAIN); + } for (i = 0; i < h->nal_length_size; i++) nalsize = ((unsigned)nalsize << 8) | buf[(*buf_index)++]; if (nalsize <= 0 || nalsize > buf_size - *buf_index) { av_log(h->avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize); - return -1; + return AVERROR_INVALIDDATA; } return nalsize; }