From 5d6b20385e1a33f4b9f2b31dfb01b30ac72830d8 Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Tue, 27 Mar 2018 16:17:59 +0800 Subject: [PATCH] [legacy]: Fix vpu_api_test memory leak issue Data in DecoderOut_t is malloc from vpu_api_legacy. And Android OMX component is following this rule for historical reason. We have to change test case to support it. Change-Id: I202525eecc461bd9507cfa2c376de11e2fc6fc9b Signed-off-by: Herman Chen --- test/vpu_api_test.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/vpu_api_test.c b/test/vpu_api_test.c index 4e546b40..fd9a1d9c 100644 --- a/test/vpu_api_test.c +++ b/test/vpu_api_test.c @@ -563,12 +563,6 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd) memset(&decOut, 0, sizeof(DecoderOut_t)); pOut = &decOut; - pOut->data = (RK_U8 *)(malloc)(sizeof(VPU_FRAME)); - if (pOut->data == NULL) { - DECODE_ERR_RET(ERROR_MEMORY); - } - memset(pOut->data, 0, sizeof(VPU_FRAME)); - ret = vpu_open_context(&ctx); if (ret || (ctx == NULL)) { DECODE_ERR_RET(ERROR_MEMORY); @@ -693,6 +687,9 @@ static RK_S32 vpu_decode_demo(VpuApiDemoCmdContext_t *cmd) ** give you a surprise. */ VPUFreeLinear(&frame->vpumem); + // NOTE: pOut->data is malloc from vpu_api we need to free it. + free(pOut->data); + pOut->data = NULL; pOut->size = 0; } }