summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-05-27 16:25:43 +0200
committerMichael Vogt <mvo@debian.org>2014-05-27 16:25:43 +0200
commit21ea1dbb50176a89e7f456f9b31220ff3097fdf2 (patch)
treef536b7ad06a46286b21a93254524af2da4e801bf /ftparchive
parent9518b448743e9030d854fcbb104516dd5ba648f6 (diff)
use free() instead of delete() when realloc is used
ContentsExtract::~ContentsExtract() needs to use free() because Data got allocated via realloc() Reported-By: clang -fsanitize=address -fno-omit-frame-pointer
Diffstat (limited to 'ftparchive')
-rw-r--r--ftparchive/cachedb.cc13
-rw-r--r--ftparchive/cachedb.h6
-rw-r--r--ftparchive/contents.cc13
-rw-r--r--ftparchive/contents.h4
-rw-r--r--ftparchive/writer.h6
5 files changed, 34 insertions, 8 deletions
diff --git a/ftparchive/cachedb.cc b/ftparchive/cachedb.cc
index e56deae1e..12eac20d8 100644
--- a/ftparchive/cachedb.cc
+++ b/ftparchive/cachedb.cc
@@ -32,6 +32,19 @@
#include <apti18n.h>
/*}}}*/
+CacheDB::CacheDB(std::string const &DB)
+ : Dbp(0), Fd(NULL), DebFile(0)
+{
+ TmpKey[0]='\0';
+ ReadyDB(DB);
+};
+
+CacheDB::~CacheDB()
+{
+ ReadyDB();
+ delete DebFile;
+};
+
// CacheDB::ReadyDB - Ready the DB2 /*{{{*/
// ---------------------------------------------------------------------
/* This opens the DB2 file for caching package information */
diff --git a/ftparchive/cachedb.h b/ftparchive/cachedb.h
index 54a274944..edb8594bf 100644
--- a/ftparchive/cachedb.h
+++ b/ftparchive/cachedb.h
@@ -156,7 +156,7 @@ class CacheDB
SHA512Bytes(0),Packages(0), Misses(0), DeLinkBytes(0) {};
} Stats;
- bool ReadyDB(std::string const &DB);
+ bool ReadyDB(std::string const &DB = "");
inline bool DBFailed() {return Dbp != 0 && DBLoaded == false;};
inline bool Loaded() {return DBLoaded == true;};
@@ -180,8 +180,8 @@ class CacheDB
bool Clean();
- CacheDB(std::string const &DB) : Dbp(0), Fd(NULL), DebFile(0) {TmpKey[0]='\0'; ReadyDB(DB);};
- ~CacheDB() {ReadyDB(std::string()); delete DebFile;};
+ CacheDB(std::string const &DB);
+ ~CacheDB();
};
#endif
diff --git a/ftparchive/contents.cc b/ftparchive/contents.cc
index 7a1fb779e..91dd2b8bd 100644
--- a/ftparchive/contents.cc
+++ b/ftparchive/contents.cc
@@ -302,7 +302,18 @@ void GenContents::DoPrint(FILE *Out,GenContents::Node *Top, char *Buf)
DoPrint(Out,Top->BTreeRight,Buf);
}
/*}}}*/
-
+// ContentsExtract Constructor /*{{{*/
+ContentsExtract::ContentsExtract()
+ : Data(0), MaxSize(0), CurSize(0)
+{
+};
+ /*}}}*/
+// ContentsExtract Destructor /*{{{*/
+ContentsExtract::~ContentsExtract()
+{
+ free(Data);
+};
+ /*}}}*/
// ContentsExtract::Read - Read the archive /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/ftparchive/contents.h b/ftparchive/contents.h
index dbbb83350..f58e3278e 100644
--- a/ftparchive/contents.h
+++ b/ftparchive/contents.h
@@ -85,8 +85,8 @@ class ContentsExtract : public pkgDirStream
bool TakeContents(const void *Data,unsigned long long Length);
void Add(GenContents &Contents,std::string const &Package);
- ContentsExtract() : Data(0), MaxSize(0), CurSize(0) {};
- virtual ~ContentsExtract() {delete [] Data;};
+ ContentsExtract();
+ virtual ~ContentsExtract();
};
#endif
diff --git a/ftparchive/writer.h b/ftparchive/writer.h
index b1a653e7d..d8a10e0bb 100644
--- a/ftparchive/writer.h
+++ b/ftparchive/writer.h
@@ -127,8 +127,10 @@ class PackagesWriter : public FTWScanner
{return Over.ReadExtraOverride(File);};
virtual bool DoPackage(string FileName);
- PackagesWriter(string const &DB,string const &Overrides,string const &ExtOverrides=string(),
- string const &Arch=string());
+ PackagesWriter(string const &DB,
+ string const &Overrides,
+ string const &ExtOverrides = "",
+ string const &Arch = "");
virtual ~PackagesWriter() {};
};