From 2480ad44abc91336d633613ad0b7aea167af366f Mon Sep 17 00:00:00 2001 From: RaymondWu Date: Wed, 1 Dec 2010 16:54:28 +0800 Subject: Fix pthread memory leakage issue. Since we use child thread to monitor parent thread. The child thread will not release resources created by parent. So we detach it manually. Change-Id: Ia7cf2f595cfd2215bdfafca6ca3da2677978d815 Signed-off-by: RaymondWu --- vmeta_lib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vmeta_lib.c b/vmeta_lib.c index b7a8c5f..a72951c 100755 --- a/vmeta_lib.c +++ b/vmeta_lib.c @@ -832,6 +832,8 @@ int vmeta_thread_monitor(struct monitor_data * pmd) if(p_cb->kernel_share_va==0 || pmd == NULL) { dbg_printf(VDEC_DEBUG_ALL,"vdec_os_api_free_user_id error: not init yet\n"); + free(pmd); + pthread_detach(pthread_self()); pthread_mutex_unlock(&pmt); return -1; } @@ -839,6 +841,8 @@ int vmeta_thread_monitor(struct monitor_data * pmd) p_md = malloc(sizeof(struct monitor_data)); if(p_md == NULL) { + free(pmd); + pthread_detach(pthread_self()); pthread_mutex_unlock(&pmt); return -1; } @@ -900,6 +904,7 @@ int vmeta_thread_monitor(struct monitor_data * pmd) pthread_attr_destroy(&pat); dbg_printf(VDEC_DEBUG_MEM,"thread monitor exit\n"); + pthread_detach(pthread_self()); pthread_mutex_unlock(&pmt); return 0; @@ -907,6 +912,7 @@ tag_monitor_fail: pthread_mutex_unlock(&pmt); free(p_md); free(pmd); + pthread_detach(pthread_self()); pthread_attr_destroy(&pat); return -1; -- cgit