From f68167a0e55c7261c9e61f0f39945cd0e908dabb Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 26 Jun 2017 17:47:38 +0200 Subject: fix some unlikely memory leaks in error cases The error cases are just as unlikely as the memory leaks to ever cause real problems, but lets play it safe for correctness. Reported-By: scan-build & clang Gbp-Dch: Ignore --- apt-pkg/edsp/edspindexfile.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'apt-pkg/edsp') diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc index 042a88cf9..2d030daaf 100644 --- a/apt-pkg/edsp/edspindexfile.cc +++ b/apt-pkg/edsp/edspindexfile.cc @@ -18,6 +18,7 @@ #include #include +#include #include /*}}}*/ @@ -61,12 +62,12 @@ std::string edspIndex::GetComponent() const pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg) { if (Pkg.IsOpen() == false) - return NULL; + return nullptr; _error->PushToStack(); - pkgCacheListParser * const Parser = new edspListParser(&Pkg); + std::unique_ptr Parser(new edspListParser(&Pkg)); bool const newError = _error->PendingError(); _error->MergeWithStack(); - return newError ? NULL : Parser; + return newError ? nullptr : Parser.release(); } /*}}}*/ // EIPP Index /*{{{*/ @@ -80,12 +81,12 @@ std::string eippIndex::GetComponent() const pkgCacheListParser * eippIndex::CreateListParser(FileFd &Pkg) { if (Pkg.IsOpen() == false) - return NULL; + return nullptr; _error->PushToStack(); - pkgCacheListParser * const Parser = new eippListParser(&Pkg); + std::unique_ptr Parser(new eippListParser(&Pkg)); bool const newError = _error->PendingError(); _error->MergeWithStack(); - return newError ? NULL : Parser; + return newError ? nullptr : Parser.release(); } /*}}}*/ -- cgit v1.2.3