From 6f34deead51a1c200589994a4cf46b7d79a45e69 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 16 Apr 2014 13:15:55 +0200 Subject: apt-private/acqprogress.cc: reset color in apt update --- apt-private/acqprogress.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc index fe7a45e12..0f5b53e50 100644 --- a/apt-private/acqprogress.cc +++ b/apt-private/acqprogress.cc @@ -267,7 +267,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner) else cout << '\r' << BlankLine << '\r' << Buffer << flush; if (_config->FindB("Apt::Color", false) == true) - cout << _config->Find("APT::Color::Neutral"); + cout << _config->Find("APT::Color::Neutral") << flush; memset(BlankLine,' ',strlen(Buffer)); BlankLine[strlen(Buffer)] = 0; -- cgit v1.2.3 From 21ea1dbb50176a89e7f456f9b31220ff3097fdf2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 27 May 2014 16:25:43 +0200 Subject: 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 --- apt-pkg/contrib/fileutl.cc | 3 ++- ftparchive/cachedb.cc | 13 +++++++++++++ ftparchive/cachedb.h | 6 +++--- ftparchive/contents.cc | 13 ++++++++++++- ftparchive/contents.h | 4 ++-- ftparchive/writer.h | 6 ++++-- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index b77c7ff7f..bfd958183 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1241,7 +1241,8 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C if (d->lzma == NULL) d->lzma = new FileFdPrivate::LZMAFILE; d->lzma->file = (FILE*) compress_struct; - d->lzma->stream = LZMA_STREAM_INIT; + lzma_stream tmp_stream = LZMA_STREAM_INIT; + d->lzma->stream = tmp_stream; if ((Mode & ReadWrite) == ReadWrite) return FileFdError("ReadWrite mode is not supported for file %s", FileName.c_str()); 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 /*}}}*/ +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() {}; }; -- cgit v1.2.3 From de6221c9d5f99a276628bcf45fb28537e46e7660 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 27 May 2014 17:49:53 +0200 Subject: Do not try to cast a pkgDepCache::Policy to a pkgCache Fix incorrect cast in pkgDepCache::Policy::GetCandidateVer() Reported-By: clang -fsanitize=address -fno-omit-frame-pointer --- apt-pkg/depcache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 19a6e0d7e..aa96ac58f 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1678,7 +1678,7 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pk { /* Not source/not automatic versions cannot be a candidate version unless they are already installed */ - VerIterator Last(*(pkgCache *)this,0); + VerIterator Last; for (VerIterator I = Pkg.VersionList(); I.end() == false; ++I) { -- cgit v1.2.3 From 7f48c4dfbb1f27c51044edde0692d7446ee74438 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 27 May 2014 23:42:10 +0200 Subject: use free() instead of delete[] in debSrcRecordParser::~debSrcRecordParser The Buffer was allocated using strndup() so we need to free it using free() instead of delete[] --- apt-pkg/deb/debsrcrecords.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index b09588dd3..a444cbe4d 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -186,6 +186,7 @@ bool debSrcRecordParser::Files(std::vector &List) /* */ debSrcRecordParser::~debSrcRecordParser() { - delete[] Buffer; + // was allocated via strndup() + free(Buffer); } /*}}}*/ -- cgit v1.2.3 From 28ba3f89659afe95fee4175d802febf895dc15a4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 May 2014 09:24:58 +0200 Subject: Fix uninitialized value Reported-By: scan-build --- test/libapt/cdrom_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libapt/cdrom_test.cc b/test/libapt/cdrom_test.cc index 626ef538e..5cf3b353c 100644 --- a/test/libapt/cdrom_test.cc +++ b/test/libapt/cdrom_test.cc @@ -91,7 +91,7 @@ TEST(CDROMTest,ReduceSourcelist) } TEST(CDROMTest, FindMountPointForDevice) { - char * tempfile; + char * tempfile = NULL; FileFd fd; createTemporaryFile("mountpoints", fd, &tempfile, "rootfs / rootfs rw 0 0\n" -- cgit v1.2.3 From b29599105ed9a5bb38b55cb066ef81256d66be41 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 May 2014 10:00:52 +0200 Subject: Fix warning about uninitialized variable Reported-By: clang++ -Werror --- apt-pkg/deb/dpkgpm.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index e410594df..613a4de9f 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1438,7 +1438,8 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) if (_config->FindB("DPkg::FlushSTDIN",true) == true && isatty(STDIN_FILENO)) { - int Flags,dummy; + int Flags; + int dummy = 0; if ((Flags = fcntl(STDIN_FILENO,F_GETFL,dummy)) < 0) _exit(100); -- cgit v1.2.3