SVACE Fix 98/233098/1 submit/tizen_5.5/20200512.104717 submit/tizen_5.5/20200513.042906
authorDewal Agarwal <d1.agarwal@samsung.com>
Tue, 12 May 2020 07:00:10 +0000 (12:30 +0530)
committerDewal Agarwal <d1.agarwal@samsung.com>
Tue, 12 May 2020 07:00:10 +0000 (12:30 +0530)
Change-Id: If00336758a96a6a4efd5bf0f732c4985de29c14d
Signed-off-by: Dewal Agarwal <d1.agarwal@samsung.com>
src/battery_dump/bd_history_item.c

index 68b78d1..07b2312 100644 (file)
@@ -685,11 +685,16 @@ static int bd_get_and_print_uid_info_entry_from_dump(int fd)
                _DBG("%s", dump_p->str);//write
                if (write(fd, dump_p->str, dump_p->len) < 0)
                        _WARN("write error");
-               int *temp_id = (int *)malloc(4);
-               *temp_id = (amap_data->id + 10000);
-               _DBG("Insert id %d, str %s, res %d", *temp_id, temp_str,
-               g_hash_table_insert(app_map, temp_id, temp_str));
                g_string_free(dump_p, TRUE);
+               int *temp_id = (int *)calloc(1, sizeof(int));
+               if (temp_id != NULL) {
+                       *temp_id = (amap_data->id + 10000);
+                       _DBG("Insert id %d, str %s, res %d", *temp_id, temp_str,
+                       g_hash_table_insert(app_map, temp_id, temp_str));
+               } else {
+                       _WARN("Memory Allocation Failed");
+                       g_free(temp_str);
+               }
        }
        bm_set_free_gslist_appid_map(list);
 
@@ -1214,6 +1219,7 @@ int bd_print_history_item_main(int fd, int num_h_items, long long base_time, boo
        // Dump the elapsed time from last event
        // It should be dumped without storing
        GString *dump_tmp_p = g_string_sized_new(30);
+       BM_CHECK_MEM_ALLOC(dump_tmp_p, {});
        struct timeval tv;
        gettimeofday(&tv, NULL);