diff options
author | Harish Mahendrakar <harish.mahendrakar@ittiam.com> | 2017-10-26 16:13:50 +0530 |
---|---|---|
committer | Nikoli Cartagena <dargeren@google.com> | 2017-11-28 21:27:51 -0800 |
commit | 37387cd891b1b27988b4d5aae7d47153aa8d752e (patch) | |
tree | aedc9f8d00fda129a71b8f9f526ed1ff9871d05a | |
parent | dcc10009e45138d0eaa4a17debf38bdcb5029ff4 (diff) | |
download | android_external_libavc-37387cd891b1b27988b4d5aae7d47153aa8d752e.tar.gz android_external_libavc-37387cd891b1b27988b4d5aae7d47153aa8d752e.tar.bz2 android_external_libavc-37387cd891b1b27988b4d5aae7d47153aa8d752e.zip |
Decoder: Handle dec_hdl memory allocation failure gracefully
If memory allocation for dec_hdl fails, return gracefully
with an error code. All other allocation failures are
handled correctly.
Bug: 68300072
Test: ran poc before/after
Change-Id: I118ae71f4aded658441f1932bd4ede3536f5028b
(cherry picked from commit 7720b3fe3de04523da3a9ecec2b42a3748529bbd)
-rw-r--r-- | decoder/ih264d_api.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c index bb5caf4..804fdb7 100644 --- a/decoder/ih264d_api.c +++ b/decoder/ih264d_api.c @@ -1490,20 +1490,37 @@ WORD32 ih264d_allocate_static_bufs(iv_obj_t **dec_hdl, void *pv_api_ip, void *pv /*****************************************************************************/ WORD32 ih264d_create(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op) { + ih264d_create_ip_t *ps_create_ip; ih264d_create_op_t *ps_create_op; WORD32 ret; + ps_create_ip = (ih264d_create_ip_t *)pv_api_ip; ps_create_op = (ih264d_create_op_t *)pv_api_op; ps_create_op->s_ivd_create_op_t.u4_error_code = 0; - + dec_hdl = NULL; ret = ih264d_allocate_static_bufs(&dec_hdl, pv_api_ip, pv_api_op); /* If allocation of some buffer fails, then free buffers allocated till then */ - if((IV_FAIL == ret) && (NULL != dec_hdl)) + if(IV_FAIL == ret) { - ih264d_free_static_bufs(dec_hdl); + if(dec_hdl) + { + if(dec_hdl->pv_codec_handle) + { + ih264d_free_static_bufs(dec_hdl); + } + else + { + void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf); + void *pv_mem_ctxt; + + pf_aligned_free = ps_create_ip->s_ivd_create_ip_t.pf_aligned_free; + pv_mem_ctxt = ps_create_ip->s_ivd_create_ip_t.pv_mem_ctxt; + pf_aligned_free(pv_mem_ctxt, dec_hdl); + } + } ps_create_op->s_ivd_create_op_t.u4_error_code = IVD_MEM_ALLOC_FAILED; ps_create_op->s_ivd_create_op_t.u4_error_code = 1 << IVD_FATALERROR; |