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: I9f4fca0739db84db023b1252c1365bfd13355541
Merged-In: I1c36821505bdc4fe6c23f30a02ab2fb0fb657946
This commit is contained in:
Ray Essick 2017-10-03 16:04:33 -07:00
parent 4b5c23e393
commit 2ae456c2a3

View file

@ -1898,6 +1898,7 @@ WORD32 ihevcd_fill_num_mem_rec(void *pv_api_ip, void *pv_api_op)
/* Request memory for buffer which holds bitstream after emulation prevention */
ps_mem_rec = &ps_mem_rec_base[MEM_REC_BITSBUF];
ps_mem_rec->u4_mem_size = MAX((max_wd_luma * max_ht_luma), MIN_BITSBUF_SIZE);
ps_mem_rec->u4_mem_size += 16; //Alloc extra for parse optimization
DEBUG("\nMemory record Id %d = %d \n", MEM_REC_BITSBUF,
ps_mem_rec->u4_mem_size);