diff options
author | Harish Mahendrakar <harish.mahendrakar@ittiam.com> | 2017-10-26 16:13:50 +0530 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-11-28 03:26:57 +0000 |
commit | 5acaa6fc86c73a750e5f4900c4e2d44bf22f683a (patch) | |
tree | aedc9f8d00fda129a71b8f9f526ed1ff9871d05a | |
parent | 6c327afb263837bc90760c55c6605b26161a4eb9 (diff) | |
download | android_external_libavc-5acaa6fc86c73a750e5f4900c4e2d44bf22f683a.tar.gz android_external_libavc-5acaa6fc86c73a750e5f4900c4e2d44bf22f683a.tar.bz2 android_external_libavc-5acaa6fc86c73a750e5f4900c4e2d44bf22f683a.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; |