tbm_bufmgr: fix leak of bo data 18/268118/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Thu, 16 Dec 2021 09:01:30 +0000 (18:01 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 16 Dec 2021 09:01:38 +0000 (18:01 +0900)
Change-Id: I8eb535679f451f0fb64f3f30094cf7801a121184

src/tbm_bufmgr.c

index c478cde..6d7ac0d 100644 (file)
@@ -1014,6 +1014,7 @@ tbm_bufmgr_internal_alloc_bo_with_bo_data(tbm_bufmgr bufmgr, tbm_bo_data *bo_dat
        bo2 = tbm_bufmgr_internal_find_bo(bufmgr, bo);
        if (bo2) {
                bo2->ref_cnt++;
+               free(bo->bo_data);
                free(bo);
                _tbm_bufmgr_mutex_unlock();
                return bo2;
@@ -1064,6 +1065,7 @@ tbm_bufmgr_internal_import_bo_with_key(tbm_bufmgr bufmgr, unsigned int key)
                TBM_TRACE_BO("find bo(%p) ref(%d) key(%d) flag(%s) in list",
                                        bo2, bo2->ref_cnt, key, _tbm_flag_to_str(bo2->flags));
                bo2->ref_cnt++;
+               free(bo->bo_data);
                free(bo);
                _tbm_set_last_result(TBM_ERROR_NONE);
                _tbm_bufmgr_mutex_unlock();
@@ -1130,6 +1132,7 @@ tbm_bufmgr_internal_import_bo_with_fd(tbm_bufmgr bufmgr, tbm_fd fd)
                TBM_TRACE_BO("find bo(%p) ref(%d) fd(%d) flag(%s) in list",
                                        bo2, bo2->ref_cnt, fd, _tbm_flag_to_str(bo2->flags));
                bo2->ref_cnt++;
+               free(bo->bo_data);
                free(bo);
                _tbm_set_last_result(TBM_ERROR_NONE);
                _tbm_bufmgr_mutex_unlock();