[pan2] Fix error found by valgrind: 8 bytes in 1 blocks are definitely lost in loss record 436 of 11, 070



commit 7f2678d7a6822760d83c14dec12304ac49f17cba
Author: Olaf Seibert <rhialto falu nl>
Date:   Mon Mar 14 23:06:18 2016 +0100

    Fix error found by valgrind: 8 bytes in 1 blocks are definitely lost in loss record 436 of 11,070
    
       at 0x4C2C12F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
       by 0x475866: main (pan.cc:976)
    
    The allocation is inlined from  data-impl.h:
    
        DataImpl (const StringView& cache_ext, Prefs& prefs, bool unit_test=false, int cache_megs=10, DataIO 
* source=new DataIO());

 pan/data-impl/data-impl.h |    1 +
 pan/data-impl/profiles.cc |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/pan/data-impl/data-impl.h b/pan/data-impl/data-impl.h
index e33cf75..08cfaa7 100644
--- a/pan/data-impl/data-impl.h
+++ b/pan/data-impl/data-impl.h
@@ -75,6 +75,7 @@ namespace pan
     **/
 
     public:
+      /* The ProfilesImpl will own and destruct the DataIO object */
       DataImpl (const StringView& cache_ext, Prefs& prefs, bool unit_test=false, int cache_megs=10, DataIO * 
source=new DataIO());
       virtual ~DataImpl ();
       virtual void save_state ();
diff --git a/pan/data-impl/profiles.cc b/pan/data-impl/profiles.cc
index 47113c5..d92efdb 100644
--- a/pan/data-impl/profiles.cc
+++ b/pan/data-impl/profiles.cc
@@ -317,4 +317,5 @@ ProfilesImpl :: save () const
 ProfilesImpl :: ~ProfilesImpl ()
 {
   save ();
+  delete &_data_io;     // we own the DataIO
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]