summaryrefslogtreecommitdiff
path: root/libavcodec/h264.c
diff options
context:
space:
mode:
authorJake Sebastian-Jones <jake.sebastian-jones@linux.com>2015-08-05 16:15:39 +1000
committerLuca Barbato <lu_zero@gentoo.org>2015-08-05 11:40:30 +0200
commit9469370fb32679352e66826daf77bdd2e6f067b5 (patch)
treed2a83ca34131fbcc60450b012240b87fc148cbf9 /libavcodec/h264.c
parente5997152f54f790229c99f237f8eb6b5b1ee683a (diff)
h264: Use AVERROR return codes instead of -1
And report why it fails. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r--libavcodec/h264.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 7c2b307787..bf2ae361f6 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1273,15 +1273,20 @@ static 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) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "AVC: The buffer size %d is too short to read "
+ "the nal length size %d at the offset %d.\n",
+ buf_size, h->nal_length_size, *buf_index);
+ return AVERROR_INVALIDDATA;
+ }
for (i = 0; i < h->nal_length_size; i++)
nalsize = (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;
}