From 8f4e7878b0df7bc4e8e3bfb65e596fb3a3e5d0b3 Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Sat, 5 Sep 2015 15:05:52 +0300 Subject: [PATCH] fix potential error from uninitialized variable --- src/StoreCache.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/StoreCache.cc b/src/StoreCache.cc index 8a9952a..fe5c583 100644 --- a/src/StoreCache.cc +++ b/src/StoreCache.cc @@ -281,6 +281,8 @@ DataRange *StoreCache::get_sum(EnumSummaryPeriod period_type_param) { res_data = NULL; cnt = 0; while(cur_date->before(max_date)) { + dr = NULL; + store = NULL; if (period_type_param == PERIOD_YEARLY) { store = new StoreCache(device_id, cur_date); dr = store->get_sum(PERIOD_MONTHLY); @@ -315,7 +317,8 @@ DataRange *StoreCache::get_sum(EnumSummaryPeriod period_type_param) { } delete(dr); } - delete(store); + if (store != NULL) + delete(store); if (period_type_param == PERIOD_YEARLY) { cur_date->next_month(); } -- 2.41.0