1436
1436
slice_count = (*buf++) + 1;
1437
1437
slices_hdr = buf + 4;
1438
1438
buf += 8 * slice_count;
1439
buf_size -= 1 + 8 * slice_count;
1440
1441
slice_count = avctx->slice_count;
1442
1443
//parse first slice header to check whether this frame can be decoded
1443
if(get_slice_offset(avctx, slices_hdr, 0) > buf_size){
1444
av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n");
1444
if(get_slice_offset(avctx, slices_hdr, 0) < 0 ||
1445
get_slice_offset(avctx, slices_hdr, 0) > buf_size){
1446
av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
1447
init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), buf_size-get_slice_offset(avctx, slices_hdr, 0));
1449
init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), (buf_size-get_slice_offset(avctx, slices_hdr, 0))*8);
1448
1450
if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){
1449
1451
av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n");
1454
1456
if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B)
1455
1457
|| (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I)
1456
1458
|| avctx->skip_frame >= AVDISCARD_ALL)
1459
1461
for(i=0; i<slice_count; i++){
1460
1462
int offset= get_slice_offset(avctx, slices_hdr, i);
1465
1467
size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
1467
if(offset > buf_size){
1468
av_log(avctx, AV_LOG_ERROR, "Slice offset is greater than frame size\n");
1469
if(offset < 0 || offset > buf_size || size < 0){
1470
av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");