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/indexfile.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'apt-pkg/indexfile.cc') diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 934943205..b860e2335 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -338,16 +338,10 @@ pkgCacheListParser * pkgDebianIndexFile::CreateListParser(FileFd &Pkg) if (Pkg.IsOpen() == false) return nullptr; _error->PushToStack(); - pkgCacheListParser * const Parser = new debListParser(&Pkg); + std::unique_ptr Parser(new debListParser(&Pkg)); bool const newError = _error->PendingError(); _error->MergeWithStack(); - if (newError) - { - delete Parser; - return nullptr; - } - else - return Parser; + return newError ? nullptr : Parser.release(); } bool pkgDebianIndexFile::Merge(pkgCacheGenerator &Gen,OpProgress * const Prog) { -- cgit v1.2.3