null checks added for battery monitor plugin 41/265041/1 submit/tizen/20211008.061900
authorChakradhar Pogiri <v.pogiri@samsung.com>
Thu, 7 Oct 2021 12:22:54 +0000 (17:52 +0530)
committerChakradhar Pogiri <v.pogiri@samsung.com>
Thu, 7 Oct 2021 12:22:54 +0000 (17:52 +0530)
Change-Id: I58987a86e2d9115fe0d267d2049b2b6c9185e4f2
Signed-off-by: Chakradhar Pogiri <v.pogiri@samsung.com>
lbs-server/src/battery-monitor/battery-monitor.c
packaging/lbs-server.spec

index 67eb814..c7a942b 100755 (executable)
@@ -246,6 +246,10 @@ static void bm_batch_update_gps_record_on_gps_off()
        gpointer key, value;
        unsigned long elapsed = 0;
 
+       if (!ht_appstatus) {
+               _E("app status table is not initialized");
+               return ;
+       }
        g_hash_table_iter_init (&iter, ht_appstatus);
        while (g_hash_table_iter_next(&iter, &key, &value)) {
                if(((const app_status*)value)->is_running) {
@@ -268,6 +272,10 @@ static void bm_batch_update_gps_record_on_demand()
        gpointer key, value;
        unsigned long elapsed = 0;
 
+       if (!ht_appstatus) {
+               _E("app status table is not initialized");
+               return ;
+       }
        g_hash_table_iter_init (&iter, ht_appstatus);
        while (g_hash_table_iter_next(&iter, &key, &value)) {
                if(((const app_status*)value)->is_running) {
@@ -363,6 +371,10 @@ static void builder_add_atm_data(GVariantBuilder *atm_builder)
        GHashTableIter iter;
        gpointer key, value;
 
+       if (!ht_apptime) {
+               _E("battery-monitor module is not initialized");
+               return ;
+       }
        g_hash_table_iter_init(&iter, ht_apptime);
        while (g_hash_table_iter_next(&iter, &key, &value)) {
                g_variant_builder_add(atm_builder, "(su)", (const char *)key, (*(unsigned int*)value));
@@ -391,6 +403,10 @@ static void gps_builder_update_gps_data(void)
        }
 
        /* if size(ht_apptime) is 0, there is no app that is using GPS */
+       if (!ht_apptime) {
+               _E("battery-monitor module is not initialized");
+               return ;
+       }
        if (g_hash_table_size(ht_apptime)) {
                t_start = timespec_to_ms(gps_session_start_t);
                t_end = timespec_to_ms(gps_session_end_t);
index 8b1757c..838b49d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:    lbs-server
 Summary: LBS Server for Tizen
-Version: 1.3.7
+Version: 1.3.8
 Release: 1
 Group:   Location/Service
 License: Apache-2.0