From: Mika Laitio Date: Sat, 5 Sep 2015 12:05:52 +0000 (+0300) Subject: fix potential error from uninitialized variable X-Git-Url: http://pilppa.org/gitweb/?p=libplp.git;a=commitdiff_plain;h=8f4e7878b0df7bc4e8e3bfb65e596fb3a3e5d0b3 fix potential error from uninitialized variable --- 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(); }