Alloc extra bytes for bits buf for parse optimzation

Without this extra allocation, if a nal fills entire bits
buffer, there will be out of bound memory read access.

Bug: 65719872
Test: ran poc before/after on ASAN of master
Change-Id: I1c36821505bdc4fe6c23f30a02ab2fb0fb657946
This commit is contained in:
Naveen Kumar P 2017-09-19 16:07:41 +05:30 committed by Ray Essick
parent a54382c9e5
commit 4cf597a518

View file

@ -1187,7 +1187,7 @@ WORD32 ihevcd_allocate_static_bufs(iv_obj_t **pps_codec_obj,
/* Request memory for static bitstream buffer which holds bitstream after emulation prevention */
size = MIN_BITSBUF_SIZE;
pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size + 16); //Alloc extra for parse optimization
RETURN_IF((NULL == pv_buf), IV_FAIL);
ps_codec->pu1_bitsbuf_static = pv_buf;
ps_codec->u4_bitsbuf_size_static = size;
@ -1880,7 +1880,7 @@ WORD32 ihevcd_allocate_dynamic_bufs(codec_t *ps_codec)
size = wd * ht;
if(size > MIN_BITSBUF_SIZE)
{
pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
pv_buf = ps_codec->pf_aligned_alloc(pv_mem_ctxt, 128, size + 16); //Alloc extra for parse optimization
RETURN_IF((NULL == pv_buf), IV_FAIL);
ps_codec->pu1_bitsbuf_dynamic = pv_buf;
ps_codec->u4_bitsbuf_size_dynamic = size;