]> pilppa.com Git - libplp.git/commitdiff
fix potential error from uninitialized variable
authorMika Laitio <lamikr@pilppa.org>
Sat, 5 Sep 2015 12:05:52 +0000 (15:05 +0300)
committerMika Laitio <lamikr@pilppa.org>
Sat, 5 Sep 2015 12:05:52 +0000 (15:05 +0300)
src/StoreCache.cc

index 8a9952a9394ac08f84f3b5cd4dd2525ee438f82d..fe5c5834be8e64f5b40d7216ba048dfd26a20034 100644 (file)
@@ -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();
                                                }