op->layers_info[j].layer_id = gf_bs_read_int(bs, 6);
op->layers_info[j].is_outputlayer = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE;
op->layers_info[j].is_alternate_outputlayer = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE;
+
+ if (gf_bs_is_overflow(bs)) {
+ gf_free(op);
+ return GF_NON_COMPLIANT_BITSTREAM;
+ }
}
op->minPicWidth = gf_bs_read_u16(bs);
op->minPicHeight = gf_bs_read_u16(bs);
op->maxBitRate = gf_bs_read_u32(bs);
op->avgBitRate = gf_bs_read_u32(bs);
}
+ if (gf_bs_is_overflow(bs)) {
+ gf_free(op);
+ return GF_NON_COMPLIANT_BITSTREAM;
+ }
gf_list_add(ptr->operating_points, op);
}
count = gf_bs_read_u8(bs);
if (ptr->scalability_mask & (1 << j))
dep->dimension_identifier[j] = gf_bs_read_u8(bs);
}
+ if (gf_bs_is_overflow(bs)) {
+ gf_free(dep);
+ return GF_NON_COMPLIANT_BITSTREAM;
+ }
gf_list_add(ptr->dependency_layers, dep);
}
bs_flush_write_cache(bs);
is_eos = gf_feof(bs->stream);
+ //cache not fully read, reset EOS
+ if (bs->cache_read && (bs->cache_read_pos<bs->cache_read_size))
+ is_eos = GF_FALSE;
/*we are in FILE mode, test for end of file*/
- if (!is_eos || bs->cache_read) {
+ if (!is_eos) {
u8 res;
Bool loc_eos=GF_FALSE;
assert(bs->position<=bs->size);
bs->EndOfStream(bs->par);
if (!bs->overflow_state) bs->overflow_state = 1;
} else {
- GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[BS] Attempt to overread bitstream\n"));
+ if (!bs->overflow_state) {
+ bs->overflow_state = 1;
+ GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[BS] Attempt to overread bitstream\n"));
+ }
}
assert(bs->position <= 1+bs->size);
return 0;