added check for missing resource 37/233037/1
authorRandeep Singh <randeep.s@samsung.com>
Mon, 11 May 2020 12:35:08 +0000 (18:05 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Mon, 11 May 2020 12:35:08 +0000 (18:05 +0530)
Change-Id: I5388e108da0850600c547ecf7d77d969bff528aa
Signed-off-by: Randeep Singh <randeep.s@samsung.com>
src/bm_power_engine.c

index cff1ae0..473b57e 100644 (file)
@@ -152,6 +152,12 @@ int bm_engine_get_total_mah_usage_by_resource_id_ci(gint resource_id, gint64 sta
                _ERR("error reported, error = %d", error);
                return BATTERY_MONITOR_ERROR_INTERNAL;
        }
+       if (resource_usage->ResourceId == NULL) {
+                _ERR("Battery Usage for ResourceId not found");
+                bm_resourceid_usage_free(resource_usage);
+                return BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND;
+       }
+
        *battery_usage = bm_calc_individual_mah_consumption(resource_usage->usage, cmah);
        bm_resourceid_usage_free(resource_usage);