Fix resource manager memory leak issue 10/235610/3 accepted/tizen/unified/20200612.022326 submit/tizen/20200611.081755
authorHyuntae Kim <ht1211.kim@samsung.com>
Mon, 8 Jun 2020 05:19:42 +0000 (14:19 +0900)
committerHyuntae Kim <ht1211.kim@samsung.com>
Thu, 11 Jun 2020 03:26:33 +0000 (12:26 +0900)
Change-Id: I1e109efe9e54aa566236d5c0857a50334e9a573f

packaging/libmm-camcorder.spec
src/mm_camcorder_rm.c

index c33c638..d539002 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.203
+Version:    0.10.204
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 0d8ccb5..104f3b2 100644 (file)
@@ -216,23 +216,37 @@ int _mmcamcorder_rm_deallocate(MMHandleType handle)
        rm_device_request_s requested;
 
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+       rm_device_return_s *r_devices;
 
        if (!hcamcorder->rm_handle) {
                _mmcam_dbg_err("Resource is not initialized ");
                return MM_ERROR_RESOURCE_NOT_INITIALIZED;
        }
 
-       if (hcamcorder->returned_devices.allocated_num > 0) {
+       r_devices = &hcamcorder->returned_devices;
+
+       if (r_devices->allocated_num > 0) {
                memset(&requested, 0x0, sizeof(rm_device_request_s));
-               requested.request_num = hcamcorder->returned_devices.allocated_num;
+               requested.request_num = r_devices->allocated_num;
                for (idx = 0; idx < requested.request_num; idx++)
-                       requested.device_id[idx] = hcamcorder->returned_devices.device_id[idx];
+                       requested.device_id[idx] = r_devices->device_id[idx];
 
                rm_ret = rm_deallocate_resources(hcamcorder->rm_handle, &requested);
                if (rm_ret != RM_OK)
                        _mmcam_dbg_err("Resource deallocation request failed ");
        }
 
+       for (idx = 0; idx < r_devices->allocated_num; idx++) {
+               if (r_devices->device_node[idx]) {
+                       free(r_devices->device_node[idx]);
+                       r_devices->device_node[idx] = NULL;
+               }
+               if (r_devices->omx_comp_name[idx]) {
+                       free(r_devices->omx_comp_name[idx]);
+                       r_devices->omx_comp_name[idx] = NULL;
+               }
+       }
+
        return MM_ERROR_NONE;
 }